kustomizer 0.1.2 → 0.1.7

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: 68396a12fb43e0ef4405296a562b431f8e4c45403b00b11043899045c2637729
4
- data.tar.gz: 48ee78953be0b1876e3176b8b7ddf1eb0f064dfc7ca29f24d3a23fb747ff521f
3
+ metadata.gz: 044c4518958413a91c1a8bc0a112220145ecdde5ab3bb043e64afe8bcffdcf40
4
+ data.tar.gz: a081394dfcd4f5e14055a93cb1561200ce2db26c7580e918a8ca31d30920d807
5
5
  SHA512:
6
- metadata.gz: 87a0e6cc3c175393548e44b120a6d14a65aa894589b0551fbc56bb550b04e3fdd77902c86b6523abc7187f9a6af3f629ec4a1b69367413b9b61b5516ff7d0d42
7
- data.tar.gz: 38323824b787ff945a22c46b2630db09af3ea667d83fce738ef96e0723b6445f6451f90b8b9205583f8c12651be76e9d8cb7df31b7be1baef054da513e5175cb
6
+ metadata.gz: 9bb48c3fd80b552860a9f4c3f7e88076678abd0b1bf5c23d94c18fb9b2013dd0e410cbb97201c9717bccda3086f34af3f7f094a7deead4d23b27e20ddf3b97ad
7
+ data.tar.gz: 3556e7605c02544f12790ab150db65ba2a937216bffa61c93909dd0ca7e0186bc83bf4ef63e7a8d3faf628ea8ce14b228baf6976cb932380cb00fe3394a3f7af
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kustomizer (0.1.2)
4
+ kustomizer (0.1.7)
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
data/lib/kustomize.rb CHANGED
@@ -5,18 +5,22 @@ require 'kustomize/session'
5
5
 
6
6
  require 'kustomize/emitter/file_emitter'
7
7
  require 'kustomize/emitter/directory_emitter'
8
+ require 'kustomize/emitter/finalizer_emitter'
8
9
  require 'kustomize/emitter/document_emitter/kustomization_document_emitter'
9
10
 
10
11
  module Kustomize
11
12
  def self.load(rel_path_or_rc, session: Kustomize::Session.new, source_path: nil)
12
- case rel_path_or_rc
13
- when String, Pathname
14
- load_path(rel_path_or_rc, session: session)
15
- when Hash
16
- load_doc(rel_path_or_rc, session: session, source_path: source_path)
17
- else
18
- raise ArgumentError, "must be a kustomization document or a path to one, instead got: #{rel_path_or_rc.inspect}"
19
- end
13
+ base_emitter =
14
+ case rel_path_or_rc
15
+ when String, Pathname
16
+ load_path(rel_path_or_rc, session: session)
17
+ when Hash
18
+ load_doc(rel_path_or_rc, session: session, source_path: source_path)
19
+ else
20
+ raise ArgumentError, "must be a kustomization document or a path to one, instead got: #{rel_path_or_rc.inspect}"
21
+ end
22
+
23
+ Kustomize::Emitter::FinalizerEmitter.new(base_emitter)
20
24
  end
21
25
 
22
26
  def self.load_doc(rc, session: Kustomize::Session.new, source_path:)
@@ -107,11 +107,8 @@ class Kustomize::Emitter::DocumentEmitter::KustomizationDocumentEmitter < Kustom
107
107
  @transforms = [
108
108
  self.namespace_transforms,
109
109
  self.image_transforms,
110
- Kustomize::Transform::FingerprintSuffixTransform.instance,
111
110
  self.json_6902_patch_transforms,
112
- self.transformer_plugin_transforms,
113
- Kustomize::Transform::RefFixupTransform.instance,
114
- Kustomize::Transform::PurgeInternalAnnotationsTransform.instance
111
+ self.transformer_plugin_transforms
115
112
  ].flatten
116
113
  end
117
114
 
@@ -0,0 +1,31 @@
1
+ require 'kustomize/emitter'
2
+
3
+ require 'kustomize/transform/fingerprint_suffix_transform'
4
+ require 'kustomize/transform/ref_fixup_transform'
5
+ require 'kustomize/transform/purge_internal_annotations_transform'
6
+
7
+ class Kustomize::Emitter::FinalizerEmitter < Kustomize::Emitter
8
+ def initialize(input_emitter)
9
+ @input_emitter = input_emitter
10
+ end
11
+
12
+ def input_emitters
13
+ [@input_emitter]
14
+ end
15
+
16
+ def transforms
17
+ return @transforms if @transforms
18
+
19
+ @transforms = [
20
+ Kustomize::Transform::FingerprintSuffixTransform.instance,
21
+ Kustomize::Transform::RefFixupTransform.instance,
22
+ Kustomize::Transform::PurgeInternalAnnotationsTransform.instance
23
+ ].flatten
24
+ end
25
+
26
+ def emit
27
+ self.transforms.inject(self.input_resources) do |rcs, xform|
28
+ xform.rewrite_all(rcs)
29
+ end
30
+ end
31
+ 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)
@@ -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.2"
2
+ VERSION = "0.1.7"
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.2
4
+ version: 0.1.7
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-22 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: accessory
@@ -63,6 +63,7 @@ files:
63
63
  - lib/kustomize/emitter/document_emitter.rb
64
64
  - lib/kustomize/emitter/document_emitter/kustomization_document_emitter.rb
65
65
  - lib/kustomize/emitter/file_emitter.rb
66
+ - lib/kustomize/emitter/finalizer_emitter.rb
66
67
  - lib/kustomize/emitter/generator_plugins_emitter.rb
67
68
  - lib/kustomize/generator_plugin.rb
68
69
  - lib/kustomize/json_6902_patch.rb