class Kustomize::Transform::NamespaceTransform

Constants

LENSES_FOR_ALL
LENSES_FOR_ALL_BLACKLIST_PAT
LENSES_FOR_KIND

Public Class Methods

new(new_ns) click to toggle source
# File lib/kustomize/transform/namespace_transform.rb, line 8
def initialize(new_ns)
  @new_ns = new_ns
end

Public Instance Methods

rewrite(rc_doc) click to toggle source
# 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