kustomizer 0.1.5 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50dca06404547fd4209e5d04a235e286e1b3d120852e28ccc6290fa8fe186cdd
4
- data.tar.gz: 6fc755d3355cfc7726f23242d4d1f0234c38ca0e1ee09d11144e3d4b5d1480a3
3
+ metadata.gz: c546f00a97a3e739f1c2448d97c3e18e0fefbeb84007a09ca0359ced2b3d7874
4
+ data.tar.gz: 4e6d9f05eea851976414c170a522429d50427582210181c052ad6ac8357ccc4f
5
5
  SHA512:
6
- metadata.gz: 8799db97dd06ad3bd6aa1156e1ea9484cfd48268003f499e4a55f8e12a38d552ae0ae612a10e0c000f5c9da674c0886035ce5b452d8e07053e7e7cdb3e1bff6f
7
- data.tar.gz: 7e75ded7af9c2b8c4f34e58dcd14e18fc5c2df62a3fdf0e5ec0fe5eaaa67bc7cfdf4f955f700adaeaff15f59024f4d20b6d667eac412659acec71912c52fb99c
6
+ metadata.gz: 2142716318d3608d8d6598c475d646b2f1c7219a08760fbe7ec9497359a5cc1a8a6996e75475c785374a8b297dd771d1aa488108172925acaed6a53a02939f2b
7
+ data.tar.gz: d45eed6a3f723f1d60e248bdddcd0a428ab668629c422662c6eddd2f4a9c7f737f17dc79156e7454be29d32dbf1fc69e90b92545d3a95d571e0600476704c9a2
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /vendor/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kustomizer (0.1.5)
5
- accessory (~> 0.1.9)
4
+ kustomizer (0.1.10)
5
+ accessory (~> 0.1.11)
6
6
  base32-multi
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- accessory (0.1.10)
11
+ accessory (0.1.11)
12
12
  base32-multi (0.1.1)
13
13
  diff-lcs (1.4.4)
14
14
  rake (13.0.3)
@@ -21,13 +21,13 @@ GEM
21
21
  rspec-expectations (3.10.1)
22
22
  diff-lcs (>= 1.2.0, < 2.0)
23
23
  rspec-support (~> 3.10.0)
24
- rspec-mocks (3.10.1)
24
+ rspec-mocks (3.10.2)
25
25
  diff-lcs (>= 1.2.0, < 2.0)
26
26
  rspec-support (~> 3.10.0)
27
- rspec-support (3.10.1)
27
+ rspec-support (3.10.2)
28
28
 
29
29
  PLATFORMS
30
- x86_64-darwin-20
30
+ ruby
31
31
 
32
32
  DEPENDENCIES
33
33
  kustomizer!
@@ -35,4 +35,4 @@ DEPENDENCIES
35
35
  rspec (~> 3.0)
36
36
 
37
37
  BUNDLED WITH
38
- 2.2.7
38
+ 1.17.2
data/kustomizer.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "A pure-ruby implementation of the Kubernetes 'kustomize' command."
13
13
  spec.homepage = "https://github.com/tsutsu/kustomize"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_runtime_dependency "accessory", "~> 0.1.9"
27
+ spec.add_runtime_dependency "accessory", "~> 0.1.11"
28
28
  spec.add_runtime_dependency "base32-multi"
29
29
  end
@@ -17,6 +17,10 @@ class Kustomize::Json6902Patch::Op
17
17
  e = e.gsub('~1', '/')
18
18
  if e == ":all"
19
19
  Accessory::Access.all
20
+ elsif e == ":first"
21
+ Accessory::Access.first
22
+ elsif e == ":last"
23
+ Accessory::Access.last
20
24
  elsif e.match?(/^\d+$/)
21
25
  e.to_i
22
26
  else
@@ -0,0 +1,36 @@
1
+ require 'kustomize/json_6902_patch'
2
+
3
+ class Kustomize::Json6902Patch::AppendOp < Kustomize::Json6902Patch::Op
4
+ def self.create(patch_spec)
5
+ elements =
6
+ if e = patch_spec['element']
7
+ [e]
8
+ elsif es = patch_spec['elements']
9
+ es
10
+ else
11
+ raise ArgumentError, "must specify one of 'element' or 'elements' in: #{patch_spec.inspect}"
12
+ end
13
+
14
+ new(
15
+ array_path: patch_spec['path'],
16
+ elements: elements
17
+ )
18
+ end
19
+
20
+ def initialize(array_path:, elements:)
21
+ @lens = parse_lens(array_path)
22
+ @new_elements = elements
23
+ end
24
+
25
+ def apply(rc)
26
+ @lens.update_in(rc) do |orig_arr|
27
+ new_arr = orig_arr.dup || []
28
+
29
+ @new_elements.each do |elem|
30
+ new_arr.push(elem)
31
+ end
32
+
33
+ [:set, new_arr]
34
+ end
35
+ end
36
+ end
@@ -22,11 +22,11 @@ class Kustomize::TargetSpec
22
22
  end
23
23
 
24
24
  def get_name(rc)
25
- rc.dig('spec', 'name')
25
+ rc.dig('metadata', 'name')
26
26
  end
27
27
 
28
28
  def get_namespace(rc)
29
- rc.dig('spec', 'namespace') || 'default'
29
+ rc.dig('metadata', 'namespace') || 'default'
30
30
  end
31
31
 
32
32
  def match?(rc)
@@ -35,7 +35,13 @@ class Kustomize::Transform::FingerprintSuffixTransform < Kustomize::Transform
35
35
  return rc unless APPLICABLE_KINDS.member?(rc_kind)
36
36
 
37
37
  FINGERPRINT_LENS.update_in(rc) do |orig_value|
38
- next(:keep) if orig_value
38
+ if orig_value
39
+ if orig_value == ''
40
+ next(:pop)
41
+ else
42
+ next(:keep)
43
+ end
44
+ end
39
45
 
40
46
  content_part = CONTENT_LENS_BY_KIND[rc_kind].get_in(rc)
41
47
  content_ser = content_part.to_json
@@ -47,9 +53,11 @@ class Kustomize::Transform::FingerprintSuffixTransform < Kustomize::Transform
47
53
  base_name = NAME_LENS.get_in(rc)
48
54
  fingerprint = FINGERPRINT_LENS.get_in(rc)
49
55
 
50
- NAME_LENS.update_in(rc) do |base_name|
51
- suffixed_name = [base_name, fingerprint].join(SUFFIX_JOINER)
52
- [:set, suffixed_name]
56
+ if fingerprint
57
+ NAME_LENS.update_in(rc) do |base_name|
58
+ suffixed_name = [base_name, fingerprint].join(SUFFIX_JOINER)
59
+ [:set, suffixed_name]
60
+ end
53
61
  end
54
62
 
55
63
  rc
@@ -23,8 +23,12 @@ class Kustomize::Transform::ImageTransform < Kustomize::Transform
23
23
  @new_digest = new_digest
24
24
  end
25
25
 
26
+ TEMPLATE_POD_SPEC_LENS = Lens["spec", "template", "spec", "containers", Access.all, "image"]
27
+
26
28
  LENS_BY_KIND = {
27
- "Deployment" => Lens["spec", "template", "spec", "containers", Access.all, "image"]
29
+ "Deployment" => TEMPLATE_POD_SPEC_LENS,
30
+ "DaemonSet" => TEMPLATE_POD_SPEC_LENS,
31
+ "StatefulSet" => TEMPLATE_POD_SPEC_LENS
28
32
  }
29
33
 
30
34
  def rewrite(rc_doc)
@@ -7,6 +7,7 @@ require 'kustomize/json_6902_patch/add_op'
7
7
  require 'kustomize/json_6902_patch/replace_op'
8
8
  require 'kustomize/json_6902_patch/remove_op'
9
9
  require 'kustomize/json_6902_patch/gsub_op'
10
+ require 'kustomize/json_6902_patch/append_op'
10
11
 
11
12
  class Kustomize::Transform::Json6902PatchTransform < Kustomize::Transform
12
13
  def self.create(kustomization_file, op_spec)
@@ -26,6 +26,10 @@ class Kustomize::Transform::NamespaceTransform < Kustomize::Transform
26
26
 
27
27
  "SealedSecret" => [
28
28
  Lens["spec", "template", "metadata", "namespace"]
29
+ ],
30
+
31
+ "ServiceMonitor" => [
32
+ Lens["spec", "namespaceSelector", "matchNames", Access.first]
29
33
  ]
30
34
  }
31
35
 
@@ -1,3 +1,3 @@
1
1
  module Kustomize
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kustomizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Aul
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: accessory
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.9
19
+ version: 0.1.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.9
26
+ version: 0.1.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: base32-multi
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +68,7 @@ files:
68
68
  - lib/kustomize/generator_plugin.rb
69
69
  - lib/kustomize/json_6902_patch.rb
70
70
  - lib/kustomize/json_6902_patch/add_op.rb
71
+ - lib/kustomize/json_6902_patch/append_op.rb
71
72
  - lib/kustomize/json_6902_patch/gsub_op.rb
72
73
  - lib/kustomize/json_6902_patch/remove_op.rb
73
74
  - lib/kustomize/json_6902_patch/replace_op.rb
@@ -93,7 +94,7 @@ licenses:
93
94
  metadata:
94
95
  homepage_uri: https://github.com/tsutsu/kustomize
95
96
  source_code_uri: https://github.com/tsutsu/kustomize
96
- post_install_message:
97
+ post_install_message:
97
98
  rdoc_options: []
98
99
  require_paths:
99
100
  - lib
@@ -101,15 +102,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
103
  - - ">="
103
104
  - !ruby/object:Gem::Version
104
- version: 2.7.0
105
+ version: 2.6.0
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.2.3
112
- signing_key:
112
+ rubygems_version: 3.0.3
113
+ signing_key:
113
114
  specification_version: 4
114
115
  summary: Pure-ruby impl of Kubernetes kustomize
115
116
  test_files: []