kucodiff 0.4.0 → 0.5.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/lib/kucodiff/version.rb +1 -1
- data/lib/kucodiff.rb +21 -20
- 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: 626cbfd398f264adaf284a4842ea250babe4d8bcb506f1700cb1629c2cfb3e3e
|
4
|
+
data.tar.gz: d3d33300480d745da896131cb1dba9881358b3d478e91ff516a3446661e33313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a87916da814015b02fcb1e5fa9b8027702eeab15a6104e3c9af2bb682daf98763d4260416962b70dda6b5b23f5e97bdfb7bc0877fb3989c1acf871f72b0c9fd
|
7
|
+
data.tar.gz: a4f29440331c0eae9a2447751e6c3b6653019d1f3f0198e591915ea8888495bf8667aa961097c5b23bd3a31c63c9f3b69a4313677c837376d8b1098f16b36256
|
data/lib/kucodiff/version.rb
CHANGED
data/lib/kucodiff.rb
CHANGED
@@ -10,12 +10,8 @@ module Kucodiff
|
|
10
10
|
|
11
11
|
diff = files.each_with_object({}) do |other, all|
|
12
12
|
other_template = read(other)
|
13
|
-
|
14
|
-
|
15
|
-
different_keys_pod_indented(base_template, other_template)
|
16
|
-
else
|
17
|
-
different_keys(base_template, other_template)
|
18
|
-
end
|
13
|
+
pod_indented!(base_template, other_template) if indent_pod
|
14
|
+
result = different_keys(base_template, other_template)
|
19
15
|
result.reject! { |k| k =~ ignore } if ignore
|
20
16
|
all["#{base}-#{other}"] = result.sort
|
21
17
|
end
|
@@ -73,22 +69,23 @@ module Kucodiff
|
|
73
69
|
annotations[key] = Hash[annotations[key].strip.split(/[\s,]/).map { |k| [k, true] }] if annotations[key]
|
74
70
|
end
|
75
71
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
72
|
+
# templates are flat hashes already
|
73
|
+
def pod_indented!(*templates)
|
74
|
+
kinds = templates.map { |t| t["kind"] }
|
75
|
+
return if (kinds & ["Pod", "PodTemplate"]).empty? || kinds.uniq.size == 1
|
76
|
+
|
77
|
+
templates.each do |template|
|
78
|
+
case template["kind"]
|
79
|
+
when "Pod"
|
80
|
+
# all good
|
81
|
+
when "PodTemplate"
|
82
|
+
template.select! { |k, _| k.start_with?("template.") }
|
83
|
+
template.transform_keys! { |k| k.sub("template.", "") }
|
84
84
|
else
|
85
|
-
template
|
85
|
+
template.select! { |k, _| k.start_with?("spec.template.") }
|
86
|
+
template.transform_keys! { |k| k.sub("spec.template.", "") }
|
86
87
|
end
|
87
88
|
end
|
88
|
-
|
89
|
-
diff = different_keys(*templates)
|
90
|
-
diff.select! { |k| k.start_with?(prefix) } if ignore_unindented
|
91
|
-
diff
|
92
89
|
end
|
93
90
|
|
94
91
|
def different_keys(a, b)
|
@@ -100,7 +97,11 @@ module Kucodiff
|
|
100
97
|
end
|
101
98
|
|
102
99
|
def template(content)
|
103
|
-
content['kind']
|
100
|
+
case content['kind']
|
101
|
+
when "Pod" then content
|
102
|
+
when "PodTemplate" then content.fetch('template')
|
103
|
+
else content.dig('spec', 'template') || {}
|
104
|
+
end
|
104
105
|
end
|
105
106
|
|
106
107
|
# http://stackoverflow.com/questions/9647997/converting-a-nested-hash-into-a-flat-hash
|
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.
|
4
|
+
version: 0.5.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: 2022-
|
11
|
+
date: 2022-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|