Class: Kustomize::Transform::FilterForSessionSpecifiedComponentTransform

Inherits:
Kustomize::Transform show all
Includes:
Accessory
Defined in:
lib/kustomize/transform/filter_for_session_specified_component_transform.rb

Constant Summary collapse

ANNOTS_LENS =
Lens['metadata', 'annotations']
COMPONENT_ANNOT_NAME =
'kustomizer.covalenthq.com/component-name'
DROP_ANNOT_NAME =
'kustomizer.covalenthq.com/drop'

Instance Method Summary collapse

Methods inherited from Kustomize::Transform

create, #inspect, #rewrite_all

Constructor Details

#initialize(component_name) ⇒ FilterForSessionSpecifiedComponentTransform

Returns a new instance of FilterForSessionSpecifiedComponentTransform.



8
9
10
# File 'lib/kustomize/transform/filter_for_session_specified_component_transform.rb', line 8

def initialize(component_name)
  @component_name = component_name
end

Instance Method Details

#rewrite(rc) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kustomize/transform/filter_for_session_specified_component_transform.rb', line 17

def rewrite(rc)
  ANNOTS_LENS.update_in(rc) do |orig_annots|
    orig_annots ||= {}

    if orig_annots[COMPONENT_ANNOT_NAME] == @component_name
      :keep
    else
      new_annots = orig_annots.merge({DROP_ANNOT_NAME => 'true'})
      [:set, new_annots]
    end
  end
end