terraorg 0.2.3 → 0.3.0
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 +25 -11
- 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: ce81d4e08d1d925fbf0cc419b5012725e33190563592d8ad491bf52a39df2920
|
4
|
+
data.tar.gz: 1854959244ef5576f9c39f3079ae73e7af243f591c972e3f79ecfb9729a87445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498d390c6eb73ff5761ccc40e8a0918d8c0e1ec8ac21d2d5862a9d9b0c7da514e574849a853cb9fce4b8516625bcb72ef6bcc39b2de52e80cbf13fef6e62a5a8
|
7
|
+
data.tar.gz: 72575c047b7565108453002e809fa2c76346e6a8998f04ff52750c065ecb48eb1b9235f0d0a6cd2e967b81292e30a668d91339b9d1bc26e7fc520669a47a750f
|
data/bin/terraorg
CHANGED
@@ -31,6 +31,7 @@ ACTIONS = [
|
|
31
31
|
'validate'
|
32
32
|
].freeze
|
33
33
|
|
34
|
+
STRICT_VALIDATION = ENV.fetch('TERRAORG_STRICT_VALIDATION', 'true')
|
34
35
|
SQUADS_FILE = ENV.fetch('TERRAORG_SQUADS', 'squads.json')
|
35
36
|
PLATOONS_FILE = ENV.fetch('TERRAORG_PLATOONS', 'platoons.json')
|
36
37
|
ORG_FILE = ENV.fetch('TERRAORG_ROOT', 'org.json')
|
@@ -95,7 +96,8 @@ platoons = Platoons.new(JSON.parse(platoons_data), squads, people, GSUITE_DOMAIN
|
|
95
96
|
org_data = File.read(ORG_FILE)
|
96
97
|
org = Org.new(JSON.parse(org_data), platoons, squads, people, GSUITE_DOMAIN)
|
97
98
|
|
98
|
-
|
99
|
+
strict = (STRICT_VALIDATION == 'true')
|
100
|
+
org.validate!(strict: strict)
|
99
101
|
|
100
102
|
case action
|
101
103
|
when 'generate-squads-md'
|
data/lib/terraorg/model/org.rb
CHANGED
@@ -49,23 +49,33 @@ class Org
|
|
49
49
|
@squads = squads
|
50
50
|
end
|
51
51
|
|
52
|
-
def validate!
|
52
|
+
def validate!(strict: true)
|
53
|
+
failure = false
|
54
|
+
|
53
55
|
# Do not allow the JSON files to contain any people who have left.
|
54
|
-
|
56
|
+
unless @people.inactive.empty?
|
57
|
+
$stderr.puts "ERROR: Users have left the company: #{@people.inactive.map(&:id).join(', ')}"
|
58
|
+
failure = true
|
59
|
+
end
|
55
60
|
|
56
61
|
# Do not allow the org to be totally empty.
|
57
|
-
|
62
|
+
if @member_platoons.size + @member_exception_squads.size == 0
|
63
|
+
$stderr.puts 'ERROR: Org has no platoons or exception squads'
|
64
|
+
failure = true
|
65
|
+
end
|
58
66
|
|
59
67
|
# Require all platoons to be part of the org.
|
60
68
|
platoon_diff = Set.new(@platoons.all_names) - Set.new(@member_platoon_names)
|
61
69
|
unless platoon_diff.empty?
|
62
|
-
|
70
|
+
$stderr.puts "ERROR: Platoons are not used in the org: #{platoon_diff.to_a.sort}"
|
71
|
+
failure = true
|
63
72
|
end
|
64
73
|
|
65
74
|
# Require all squads to be used in the org.
|
66
75
|
squad_diff = Set.new(@squads.all_names) - Set.new(@platoons.all_squad_names) - Set.new(@member_exception_squad_names)
|
67
76
|
unless squad_diff.empty?
|
68
|
-
|
77
|
+
$stderr.puts "ERROR: Squad(s) are not used in the org: #{squad_diff.to_a.sort}"
|
78
|
+
failure = true
|
69
79
|
end
|
70
80
|
|
71
81
|
all_squads = (@member_platoons.map(&:member_squads) + @member_exception_squads).flatten
|
@@ -79,7 +89,8 @@ class Org
|
|
79
89
|
count > 1
|
80
90
|
end
|
81
91
|
if !more_than_one_platoon.empty?
|
82
|
-
|
92
|
+
$stderr.puts "ERROR: Squads are part of more than one platoon: #{more_than_one_platoon}"
|
93
|
+
failure = true
|
83
94
|
end
|
84
95
|
|
85
96
|
# Validate that a squad member belongs to some maximum number of squads
|
@@ -93,8 +104,8 @@ class Org
|
|
93
104
|
count > MAX_MEMBER_SQUADS_PER_PERSON
|
94
105
|
end
|
95
106
|
if !more_than_max_squads.empty?
|
96
|
-
|
97
|
-
|
107
|
+
$stderr.puts "ERROR: People are members of more than #{MAX_MEMBER_SQUADS_PER_PERSON} squads: #{more_than_max_squads}"
|
108
|
+
failure = true
|
98
109
|
end
|
99
110
|
|
100
111
|
associate_count = {}
|
@@ -105,8 +116,8 @@ class Org
|
|
105
116
|
count > MAX_ASSOCIATE_SQUADS_PER_PERSON
|
106
117
|
end
|
107
118
|
if !more_than_max_squads.empty?
|
108
|
-
|
109
|
-
|
119
|
+
$stderr.puts "ERROR: People are associates of more than #{MAX_ASSOCIATE_SQUADS_PER_PERSON} squads: #{more_than_max_squads}"
|
120
|
+
failure = true
|
110
121
|
end
|
111
122
|
|
112
123
|
# Validate that a squad member is not also an org exception
|
@@ -115,8 +126,11 @@ class Org
|
|
115
126
|
exceptions.member? member
|
116
127
|
end
|
117
128
|
if !exception_and_squad_member.empty?
|
118
|
-
|
129
|
+
$stderr.puts "ERROR: Exception members are also squad members: #{exception_and_squad_member}"
|
130
|
+
failure = true
|
119
131
|
end
|
132
|
+
|
133
|
+
raise "CRITICAL: Validation failed due to at least one error above" if failure && strict
|
120
134
|
end
|
121
135
|
|
122
136
|
def members
|
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.
|
4
|
+
version: 0.3.0
|
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-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|