kustomizer 0.1.3 → 0.1.8

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: 4f39b98c4f11fd4d80b1a70192211c56532c9033b7f4c9f6fe14ccbf92651f90
4
- data.tar.gz: 652461e4c5610ec39a669ee4c224eba7e0d513e96feccb9c3433363b5c8cb659
3
+ metadata.gz: 1260ca0cca8efac0126311bef3132cdf7bc365f972796cc79af0f93f104ffdf9
4
+ data.tar.gz: a185196ef16998e4ff770e3c3de43bebdd73803b8191f1d2848e85df0139bcc5
5
5
  SHA512:
6
- metadata.gz: 7068ff28557ca6c1eea591e2e5dbddb8ef666621f575417a08393c78c87ec6e1522b273b70efc433577e126df7eed821a472593f036169c54e23b1793c64350c
7
- data.tar.gz: beea6d68509ff19341f0c995baf6211ebec1d39c7116efd3effef9d3b8f12a4171e5d84f05f909380e5b1e2a449914d389bed20809dd9da6ddf7364ace15481e
6
+ metadata.gz: 2cc5cf3fab625e3e33acc67beba765bd59d8601484648107ba777814df91c0f789dd9f672ebb8912752d6e4021a60cc092f4b36482be73507b25aaaf126ce8e6
7
+ data.tar.gz: efe6654e4cfbebf32c6fc93a9cebfaed0c8ee67dfd4dcbb44a38fddbf5d65031fb7c76f5282b370d53dd27eb390e8a7947ac2628d16e8edc6d3b7b5e13c66a6f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kustomizer (0.1.3)
4
+ kustomizer (0.1.8)
5
5
  accessory (~> 0.1.9)
6
6
  base32-multi
7
7
 
@@ -35,4 +35,4 @@ DEPENDENCIES
35
35
  rspec (~> 3.0)
36
36
 
37
37
  BUNDLED WITH
38
- 2.2.6
38
+ 2.2.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
@@ -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
 
@@ -14,8 +14,7 @@ class Kustomize::Transform::RefFixupTransform < Kustomize::Transform
14
14
 
15
15
  FINGERPRINT_LENS = Lens['metadata', 'annotations', 'kustomizer.covalenthq.com/effective-fingerprint']
16
16
 
17
- KEY_REF_LENSES_BY_KIND = {
18
- "Deployment" => [
17
+ POD_TEMPLATE_LENSES = [
19
18
  Lens["spec", "template", "spec", "containers", Access.all, "envFrom", Access.all, "configMapRef", "name"],
20
19
  Lens["spec", "template", "spec", "containers", Access.all, "env", Access.all, "valueFrom", "configMapKeyRef", "name"],
21
20
  Lens["spec", "template", "spec", "volumes", Access.all, "configMap", "name"],
@@ -23,7 +22,12 @@ class Kustomize::Transform::RefFixupTransform < Kustomize::Transform
23
22
  Lens["spec", "template", "spec", "containers", Access.all, "env", Access.all, "valueFrom", "secretKeyRef", "name"],
24
23
  Lens["spec", "template", "spec", "volumes", Access.all, "secret", "name"],
25
24
  Lens["spec", "template", "spec", "volumes", Access.all, "secret", "secretName"]
26
- ]
25
+ ]
26
+
27
+ KEY_REF_LENSES_BY_KIND = {
28
+ "Deployment" => POD_TEMPLATE_LENSES,
29
+ "StatefulSet" => POD_TEMPLATE_LENSES,
30
+ "DaemonSet" => POD_TEMPLATE_LENSES
27
31
  }
28
32
 
29
33
  def rewrite_all(rcs)
@@ -1,3 +1,3 @@
1
1
  module Kustomize
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
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.3
4
+ version: 0.1.8
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-25 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