Class: Kdep::ConfigmapOverlay
- Inherits:
-
Object
- Object
- Kdep::ConfigmapOverlay
- Defined in:
- lib/kdep/configmap_overlay.rb
Overview
Overlays rich configmap data from external files onto a helm-owned configmap. Runs after ‘helm upgrade –install` so the chart creates the configmap first; this module rewrites its data keys without touching helm-set labels or annotations.
Two merge strategies:
replace — fetch live configmap, replace `data:` with only the listed
keys, `kubectl apply` the full manifest back.
patch — emit a JSON patch that adds/updates only the listed keys,
leaving any other data helm wrote intact.
First-deploy safety: if the configmap does not yet exist (chart hasn’t run yet), the overlay is skipped with a warning; a re-run picks it up.
Defined Under Namespace
Instance Method Summary collapse
- #apply! ⇒ Object
-
#initialize(overlay, namespace:, path_resolver:, ui:, dry_run: false) ⇒ ConfigmapOverlay
constructor
A new instance of ConfigmapOverlay.
- #merge_strategy ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(overlay, namespace:, path_resolver:, ui:, dry_run: false) ⇒ ConfigmapOverlay
Returns a new instance of ConfigmapOverlay.
24 25 26 27 28 29 30 |
# File 'lib/kdep/configmap_overlay.rb', line 24 def initialize(, namespace:, path_resolver:, ui:, dry_run: false) @overlay = @namespace = namespace @resolver = path_resolver @ui = ui @dry_run = dry_run end |
Instance Method Details
#apply! ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/kdep/configmap_overlay.rb', line 40 def apply! case merge_strategy when "replace" then apply_replace! when "patch" then apply_patch! else raise Error, "configmap_overlay #{name}: unknown merge strategy '#{merge_strategy}' (expected replace|patch)" end end |
#merge_strategy ⇒ Object
36 37 38 |
# File 'lib/kdep/configmap_overlay.rb', line 36 def merge_strategy (@overlay["merge"] || "replace").to_s end |
#name ⇒ Object
32 33 34 |
# File 'lib/kdep/configmap_overlay.rb', line 32 def name @overlay["name"] end |