terraorg 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/terraorg +3 -1
- data/lib/terraorg/model/org.rb +8 -5
- data/lib/terraorg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2104b8065449ba79b76d2186b17ba12df520939976a78e89baffdb480003c1a4
|
4
|
+
data.tar.gz: 5fed899d94b706ec33a93355facfa444a37275b0632dd738d96e0da9f3a142bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6abcbaf53d3205dc7e680015e6bf9cb52d727a9cfac507c6b797f47adc704a7b83b6777a2f53b99a8db9abb37666196439b3b20bfad53fee44fb8812fee83156
|
7
|
+
data.tar.gz: 371bd8f5f19db6add483887aeefba418cf67dfcef48ec76a3ee506a168fdf543f439d330d0431c9a38d22a6c0b5ab3826993e2a95919461edd7ca3b1b7991f0f
|
data/bin/terraorg
CHANGED
@@ -32,6 +32,7 @@ ACTIONS = [
|
|
32
32
|
].freeze
|
33
33
|
|
34
34
|
STRICT_VALIDATION = ENV.fetch('TERRAORG_STRICT_VALIDATION', 'true')
|
35
|
+
ALLOW_ORPHANED_ASSOCIATES = ENV.fetch('ALLOW_ORPHANED_ASSOCIATES', 'false')
|
35
36
|
SQUADS_FILE = ENV.fetch('TERRAORG_SQUADS', 'squads.json')
|
36
37
|
PLATOONS_FILE = ENV.fetch('TERRAORG_PLATOONS', 'platoons.json')
|
37
38
|
ORG_FILE = ENV.fetch('TERRAORG_ROOT', 'org.json')
|
@@ -97,7 +98,8 @@ org_data = File.read(ORG_FILE)
|
|
97
98
|
org = Org.new(JSON.parse(org_data), platoons, squads, people, GSUITE_DOMAIN)
|
98
99
|
|
99
100
|
strict = (STRICT_VALIDATION == 'true')
|
100
|
-
|
101
|
+
allow_orphaned_associates = (ALLOW_ORPHANED_ASSOCIATES == 'true')
|
102
|
+
org.validate!(strict: strict, allow_orphaned_associates)
|
101
103
|
|
102
104
|
case action
|
103
105
|
when 'generate-squads-md'
|
data/lib/terraorg/model/org.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Copyright 2019-2020 LiveRamp Holdings, Inc.
|
2
|
+
# Copyright 2020- Joshua Kwan
|
2
3
|
#
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
5
|
# you may not use this file except in compliance with the License.
|
@@ -49,7 +50,7 @@ class Org
|
|
49
50
|
@squads = squads
|
50
51
|
end
|
51
52
|
|
52
|
-
def validate!(strict: true)
|
53
|
+
def validate!(strict: true, allow_orphaned_associates: false)
|
53
54
|
failure = false
|
54
55
|
|
55
56
|
# Do not allow the JSON files to contain any people who have left.
|
@@ -133,10 +134,12 @@ class Org
|
|
133
134
|
end
|
134
135
|
|
135
136
|
# Validate that any associate is a member of some squad
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
if !allow_orphaned_associates
|
138
|
+
associates_but_not_members = Set.new(all_associates.map(&:id)) - Set.new(all_members.map(&:id)) - exceptions
|
139
|
+
if !associates_but_not_members.empty?
|
140
|
+
$stderr.puts "ERROR: #{associates_but_not_members.to_a} are associates of squads but not members of any squad"
|
141
|
+
failure = true
|
142
|
+
end
|
140
143
|
end
|
141
144
|
|
142
145
|
raise "CRITICAL: Validation failed due to at least one error above" if failure && strict
|
data/lib/terraorg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraorg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Kwan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|