knife-tidy 0.4.0 → 0.4.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
  SHA1:
3
- metadata.gz: 5c88d6c7424cf8313b281efc0f68e2d635df4fae
4
- data.tar.gz: 2fb450888ca5ca8d612b73efcb810806314246b8
3
+ metadata.gz: fdd8bded909178ab1e6055a4415dc0c675ee0441
4
+ data.tar.gz: 52b73bfc270082947f232fd333ecdd900bac2ac7
5
5
  SHA512:
6
- metadata.gz: c63e4dd5f37b8a9cf028430455727243d944e01b13bca25b4562d00ea16b8fed5a86d47adcc727935197e95dfd60792d5cbcda7f6ca4f85a6ea580acdffefcd1
7
- data.tar.gz: cbdeb1bca74cee204b16ec6bb89c6bab18263d73f98268a58197a2bd8b8d9107cfeac88298c522d543cadc63854ba1f1a4f08647bf2a735ae12332143e9a8804
6
+ metadata.gz: e843f9db36f6baf438c500ff2fd52b8e7e7151f06391597c3809dd52b4bf89124ba7a9cd2579d090c1eb9280b92145ff09a2738a799275cbb4bfb8de75b1865e
7
+ data.tar.gz: 7dcb30b9c176ccb3b087cbecdfdbe4ec03854c32643eb7de6b7592a24ae1d58a7b8009a3ce1ab0f38ddcab16114f9eae005ee6505958c4c4987a1f80133d5278
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.4.1](https://github.com/chef-customers/knife-tidy/tree/0.4.1) (2017-09-27)
4
+ [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.4.0...0.4.1)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - fixing corrupt invitations and invalid platform names with commas in … [\#38](https://github.com/chef-customers/knife-tidy/pull/38) ([jeremymv2](https://github.com/jeremymv2))
9
+ - bump to 0.4.0 [\#36](https://github.com/chef-customers/knife-tidy/pull/36) ([jeremymv2](https://github.com/jeremymv2))
10
+
3
11
  ## [0.4.0](https://github.com/chef-customers/knife-tidy/tree/0.4.0) (2017-09-26)
4
12
  [Full Changelog](https://github.com/chef-customers/knife-tidy/compare/0.3.6...0.4.0)
5
13
 
@@ -51,6 +51,7 @@ class Chef
51
51
 
52
52
  orgs.each do |org|
53
53
  fix_org_object(org)
54
+ validate_invitations(org)
54
55
  validate_roles(org)
55
56
  org_acls = Chef::TidyOrgAcls.new(tidy, org)
56
57
  org_acls.validate_acls
@@ -213,6 +214,8 @@ class Chef
213
214
  end
214
215
  if metadata.has_key?('platforms')
215
216
  metadata['platforms'].each_pair do |key, value|
217
+ # platform key cannot contain comma delimited values
218
+ md['platforms'].delete(key) if key =~ /,/
216
219
  if value.kind_of?(Array) && value.empty?
217
220
  puts "REPAIRING: Fixing empty platform key for for key #{key} in #{json_path}"
218
221
  md['platforms'][key] = '>= 0.0.0'
@@ -365,6 +368,26 @@ class Chef
365
368
  end
366
369
  end
367
370
  end
371
+
372
+ def validate_invitations(org)
373
+ invite_file = tidy.invitations_path(org)
374
+ puts "INFO: validating org #{org} invites in #{invite_file}"
375
+ invitations = FFI_Yajl::Parser.parse(::File.read(invite_file), symbolize_names: false)
376
+ invitations_new = []
377
+ invitations.each do |invite|
378
+ if invite['username'].nil?
379
+ puts "REPAIRING: Dropping corrupt invitations for #{org} in file #{invite_file}"
380
+ else
381
+ invite_hash = {}
382
+ invite_hash['id'] = invite['id']
383
+ invite_hash['username'] = invite['username']
384
+ invitations_new.push(invite_hash)
385
+ end
386
+ end
387
+ ::File.open(invite_file, 'w') do |f|
388
+ f.write(Chef::JSONCompat.to_json_pretty(invitations_new))
389
+ end
390
+ end
368
391
  end
369
392
  end
370
393
  end
@@ -17,6 +17,10 @@ class Chef
17
17
  ::File.expand_path(::File.join(@backup_path, 'organizations', org, 'members.json'))
18
18
  end
19
19
 
20
+ def invitations_path(org)
21
+ ::File.expand_path(::File.join(@backup_path, 'organizations', org, 'invitations.json'))
22
+ end
23
+
20
24
  def clients_path(org)
21
25
  ::File.expand_path(::File.join(@backup_path, 'organizations', org, 'clients'))
22
26
  end
@@ -1,4 +1,4 @@
1
1
  module KnifeTidy
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  MAJOR, MINOR, TINY = VERSION.split('.')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-tidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-26 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake