Class: Kustomize::Transform::NamespaceTransform
- Inherits:
-
Kustomize::Transform
- Object
- Kustomize::Transform
- Kustomize::Transform::NamespaceTransform
- Includes:
- Accessory
- Defined in:
- lib/kustomize/transform/namespace_transform.rb
Constant Summary collapse
- LENSES_FOR_ALL =
[ Lens["metadata", "namespace"] ]
- LENSES_FOR_ALL_BLACKLIST_PAT =
/^Cluster/
- LENSES_FOR_KIND =
{ "ClusterRoleBinding" => [ Lens["subjects", Access.all, "namespace"] ], "RoleBinding" => [ Lens["subjects", Access.all, "namespace"] ], "SealedSecret" => [ Lens["spec", "template", "metadata", "namespace"] ], "ServiceMonitor" => [ Lens["spec", "namespaceSelector", "matchNames", Access.first] ] }
Instance Method Summary collapse
-
#initialize(new_ns) ⇒ NamespaceTransform
constructor
A new instance of NamespaceTransform.
- #rewrite(rc_doc) ⇒ Object
Methods inherited from Kustomize::Transform
create, #inspect, #rewrite_all
Constructor Details
#initialize(new_ns) ⇒ NamespaceTransform
Returns a new instance of NamespaceTransform.
8 9 10 |
# File 'lib/kustomize/transform/namespace_transform.rb', line 8 def initialize(new_ns) @new_ns = new_ns end |
Instance Method Details
#rewrite(rc_doc) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kustomize/transform/namespace_transform.rb', line 36 def rewrite(rc_doc) rc_kind = rc_doc['kind'] use_lenses = [] unless rc_kind =~ LENSES_FOR_ALL_BLACKLIST_PAT use_lenses += LENSES_FOR_ALL end if lenses_for_doc_kind = LENSES_FOR_KIND[rc_kind] use_lenses += lenses_for_doc_kind end use_lenses.inject(rc_doc) do |doc, lens| lens.put_in(doc, @new_ns) end end |