kucodiff 0.3.0 → 0.4.0

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: 7ee341354f388e8f3ec330e0a6bdfb8932f930cc22002abeba9231f907ec2757
4
- data.tar.gz: 95373625d0a01aaebc3f2b4ad8a0993f1dfc05069def44e478d566f037221b4c
3
+ metadata.gz: e0c86b43c39bc7d8aa5fcb41035d254e8ce47e89969d97b4b1d0e5829ffeb139
4
+ data.tar.gz: b2da356c812dd537b04dfb5c327165ce895d182f1dc5a180cb1c335df93640d7
5
5
  SHA512:
6
- metadata.gz: 246489f2d7f29fee218a1b6924143b736945092e343f91a09e2bcd3a6cdadebb4de875102c74f7c44c9343ee9b58d0b8a8474068604b7c8db99e787bd4584686
7
- data.tar.gz: 3ada56f41b856de3ffc0a0e260e5881d53d41c08d77826313ef1ddfd48273fe3ac061cff0d3be0c72ea1c7d81af5cce51c7506a0106e8f23bf463d54ed74d58c
6
+ metadata.gz: 5ab4d4c2642f15fdf86798402f60115afd74787a81b49e6ce664f39e8d36873af440316c0c297d2543721ec43b11a4d22301810948786b5e4a6fc4b545b1f4e2
7
+ data.tar.gz: fdd69911a3a957c611a947044cf8f16293eac9fcc707c4d712409dd019fef6c979bb9f2ddec1f5098da167beab165d63dbd460a16b06c36e303e5ce2e74d2731
@@ -1,3 +1,3 @@
1
1
  module Kucodiff
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/kucodiff.rb CHANGED
@@ -42,21 +42,28 @@ module Kucodiff
42
42
  raise ArgumentError, "unknown file format in #{file}"
43
43
  end.first
44
44
 
45
- hashify_container_env!(content)
45
+ template = template(content)
46
+ template.dig("spec", "containers")&.each do |container|
47
+ hashify_named_array!(container, "env", first: true)
48
+ hashify_named_array!(container, "volumeMounts", first: false)
49
+ end
50
+ hashify_named_array!(template["spec"], "volumes", first: false)
46
51
  hashify_required_env!(content)
47
52
 
48
53
  flat_hash(content)
49
54
  end
50
55
 
51
- # make env comparable
52
- def hashify_container_env!(content)
53
- containers = template(content).fetch('spec', {}).fetch('containers', [])
54
- containers.each do |container|
55
- next unless container['env']
56
- container['env'] = container['env'].each_with_object({}) do |v, h|
57
- value_key = (v.keys - ['name']).first
58
- h[v.fetch('name')] = v.fetch(value_key)
59
- end
56
+ def hashify_named_array!(object, key, first:)
57
+ return if !object || !(array = object[key])
58
+ object[key] = array.to_h do |v|
59
+ keep = (v.keys - ['name'])
60
+ value =
61
+ if first
62
+ v.fetch(keep.first)
63
+ else
64
+ v.slice(*keep)
65
+ end
66
+ [v.fetch('name'), value]
60
67
  end
61
68
  end
62
69
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kucodiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-29 00:00:00.000000000 Z
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it
@@ -31,14 +31,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 2.5.0
34
+ version: 2.6.0
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubygems_version: 3.1.3
41
+ rubygems_version: 3.1.6
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: Smart diff for kubernetes configs to ensure symmetric configuration