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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/kustomize.rb +12 -8
- data/lib/kustomize/emitter/document_emitter/kustomization_document_emitter.rb +1 -4
- data/lib/kustomize/emitter/finalizer_emitter.rb +31 -0
- data/lib/kustomize/target_spec.rb +4 -4
- data/lib/kustomize/transform/image_transform.rb +5 -1
- data/lib/kustomize/transform/namespace_transform.rb +4 -0
- data/lib/kustomize/transform/ref_fixup_transform.rb +7 -3
- data/lib/kustomize/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 044c4518958413a91c1a8bc0a112220145ecdde5ab3bb043e64afe8bcffdcf40
|
4
|
+
data.tar.gz: a081394dfcd4f5e14055a93cb1561200ce2db26c7580e918a8ca31d30920d807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb48c3fd80b552860a9f4c3f7e88076678abd0b1bf5c23d94c18fb9b2013dd0e410cbb97201c9717bccda3086f34af3f7f094a7deead4d23b27e20ddf3b97ad
|
7
|
+
data.tar.gz: 3556e7605c02544f12790ab150db65ba2a937216bffa61c93909dd0ca7e0186bc83bf4ef63e7a8d3faf628ea8ce14b228baf6976cb932380cb00fe3394a3f7af
|
data/Gemfile.lock
CHANGED
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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('
|
25
|
+
rc.dig('metadata', 'name')
|
26
26
|
end
|
27
27
|
|
28
28
|
def get_namespace(rc)
|
29
|
-
rc.dig('
|
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(
|
41
|
-
return false if @match_namespace and get_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" =>
|
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
|
-
|
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)
|
data/lib/kustomize/version.rb
CHANGED
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
|
+
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-
|
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
|