terraorg 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46107b71a1eace06c51463513c5b495b9549ec19ebc911103ec0d7f236fec6f8
4
- data.tar.gz: b05708c67d359a3040eca8724140603d5c4debd6e2f1a25c87034e8a9b60e7be
3
+ metadata.gz: 2104b8065449ba79b76d2186b17ba12df520939976a78e89baffdb480003c1a4
4
+ data.tar.gz: 5fed899d94b706ec33a93355facfa444a37275b0632dd738d96e0da9f3a142bf
5
5
  SHA512:
6
- metadata.gz: 9f9286df25676340a5e3a36221f5b7de4ed21cce63281850210f18b360474544e453939b8b4559dec6cb58dfa0b9ce5facca21570f03295cb5f9d0b5c56eff57
7
- data.tar.gz: 196d63d8df921c54216511ee7604b6ec8f8813241609a1fb0c4fa5480d965c4d2e9f0b2042a0f55a46b1fbaa8cb633f50317608afbf68f71d42b8b00fc877f83
6
+ metadata.gz: 6abcbaf53d3205dc7e680015e6bf9cb52d727a9cfac507c6b797f47adc704a7b83b6777a2f53b99a8db9abb37666196439b3b20bfad53fee44fb8812fee83156
7
+ data.tar.gz: 371bd8f5f19db6add483887aeefba418cf67dfcef48ec76a3ee506a168fdf543f439d330d0431c9a38d22a6c0b5ab3826993e2a95919461edd7ca3b1b7991f0f
@@ -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
- org.validate!(strict: strict)
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'
@@ -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
- associates_but_not_members = Set.new(all_associates.map(&:id)) - Set.new(all_members.map(&:id)) - exceptions
137
- if !associates_but_not_members.empty?
138
- $stderr.puts "ERROR: #{associates_but_not_members.map(&:id)} are associates of squads but not members of any squad"
139
- failure = true
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
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module Terraorg
16
- VERSION = '0.5.0'
16
+ VERSION = '0.5.1'
17
17
  end
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries