kustomizer 0.1.4 → 0.1.9

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: 488be81bc2cbf22fdb68614216b86dfe0aaed6ad370b7beca33b235917e4eac5
4
- data.tar.gz: 17a614a19a36d59860ea5542b8939122539d599b81ef8cc6ed8aef9ab5eddbff
3
+ metadata.gz: babe9435689f3621c9ae15695634702cafaec38bf59dda8a1ea48693156a00a6
4
+ data.tar.gz: 895bc312069b35b30fbe89a5851213cdef4bba9e181ca29fd3ebb87fb05fb28b
5
5
  SHA512:
6
- metadata.gz: 85192a2d5c5e92c6170b33bb030f42051c674d6ac294de6348b38eb6ae2ebe625d768f1687b5fad78d064c0388f0a5e919c83970f5f641a8f3906399556b452a
7
- data.tar.gz: 22b1660cf1750b0869a09a43f8d9a2a331ddcbe1f2de38eb1026d2cd543feea66bb943a9c7596acba5996e1a8caa3f8186d4deceafe499ab9f980ab28a3be05a
6
+ metadata.gz: 525e73552ce0429c7e9ceeba3313af956837db05ba9f82c6459b814b65842caea74c7d2f4fa447bf9b9c66c2ace9608b8b539f69abf4579a526d1c9af9889ac1
7
+ data.tar.gz: 1c35d9b12473299f2727d4b48c728bb5f8310b9676f21cf2393351e393a81ea7a0ec57086f72c4bf4e580f327567087911637fc7eb9961f69cc73764359ec6e5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kustomizer (0.1.4)
4
+ kustomizer (0.1.9)
5
5
  accessory (~> 0.1.9)
6
6
  base32-multi
7
7
 
@@ -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)
@@ -37,8 +37,8 @@ class Kustomize::TargetSpec
37
37
  end
38
38
 
39
39
  return false if @match_kind and (rc['kind'] != @match_kind)
40
- return false if @match_name and get_name(resource_doc) != @match_name
41
- return false if @match_namespace and get_namespace(resource_doc) != @match_namespace
40
+ return false if @match_name and get_name(rc) != @match_name
41
+ return false if @match_namespace and get_namespace(rc) != @match_namespace
42
42
 
43
43
  true
44
44
  end
@@ -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.4"
2
+ VERSION = "0.1.9"
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.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Aul
8
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
@@ -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