kubernetes_template_rendering 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0eb9fa164f3a7e9f58a0d0e0962fb7de3be1efb3f4f5b3fba0d3c348355f993d
4
- data.tar.gz: 49c13404c0dcc1e707927139df37d00272d8872715255590d1a12168f94fbe6a
3
+ metadata.gz: 7c71eb502c7b52355ee6d9040a8401a6e7937477b4ffc81b725951187340e325
4
+ data.tar.gz: 07e31b80f5c7c2e0d95860d10a4a73390dd919eeed86000867e151faad9f7113
5
5
  SHA512:
6
- metadata.gz: 0b5e80e69fff3dfa08384bcf851b63bb3af692accd1ca0dfdc825dcddeb077c181915ad95ef9b2de3061d9daf4b015fe9b7481d03f009c019cd1524d75c58240
7
- data.tar.gz: 26a072a724c6828e96890386b653cf649566f363bae9085c01ae0e8fd338f2ebe350fcffc4cbf96089a67f2458430562cceee87d4e4cf682fbb0f34834b7d4f8
6
+ metadata.gz: 3113be1c65d2e3f356e82b0b3388f9a090fab3945dcc9c54720146f12f9f95d8c95e7dd7fae7af0c00687aa6e557cf84c7fc6de5754f16c7e831fe101b283770
7
+ data.tar.gz: 64b29afd0de7680e0a8c4aa57010268bc3e1e0bb6ec502c11d91e1ac518d633371d8b1b8f7fa368cb71b73f5e89754e42fecc36cbdd56e698077064269316e0a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.6.2] - 2026-07-15
8
+ ### Fixed
9
+ - Fixed the `--reconcile` sweep root for entries whose `subdirectory:` nests more than one level deep (e.g. `subdirectory: exclude-argocd/auth`). The sweep root is now the entry's canonical base — `<region>/<cluster_type>/<color>` for non-SPP entries and `<region>/<cluster_type>/<color>/spp/SPP-PLACEHOLDER` for SPP entries — regardless of `subdirectory:` depth, rather than the immediate parent of the rendered output directory. Previously a nested `subdirectory:` pushed the sweep root one level too deep, so when a `subdirectory:` was renamed or nested deeper the files left at the old shallower path were siblings of the sweep root and were never swept.
10
+
11
+ ### Changed
12
+ - Under `--reconcile`, non-SPP entries must now render within their canonical `<region>/<cluster_type>/<color>` base; an entry that renders outside it (only reachable via the deprecated `directory:` field) hard-errors before any writes. This completes the reconcile layout hard-validation deferred in ADR-0001 — SPP entries were already constrained to the `spp/SPP-PLACEHOLDER` prefix. See ADR-0001.
13
+
14
+ ## [0.6.1] - 2026-07-08
15
+ ### Fixed
16
+ - Fixed `variable_overrides` and `source_repo` not being forwarded to child `Resource` instances created by `DeployGroupedResource`. Previously, `--variable-override` values (e.g. `deploySha`) were silently unavailable inside all `*-deploy.jsonnet` and `*-deploy.yaml.erb` templates, causing a `KeyError` at render time. `DeployGroupedResource#initialize` now accepts both as optional keyword arguments and passes them through to each `Resource.new` call in `#render`. `ResourceSet#grouped_resources` is updated to supply both values.
17
+
7
18
  ## [0.6.0] - 2026-07-06
8
19
  ### Added
9
20
  - Added `--reconcile` flag: a bounded, marker-based sweep that replaces the destructive per-entry `rm -rf` of `--prune`. It touches a marker before rendering, then after rendering deletes only files older than the marker under each scope root (`<region>/<cluster_type>/<color>/`) and removes empty directories, correctly cleaning up directories of deleted/renamed entries. `spp/` subtrees are fenced out of the base sweep, paths resolving outside their scope prefix raise a hard error, and `--reconcile` combined with `--prune` is rejected.
data/catalog-info.yaml CHANGED
@@ -32,5 +32,6 @@ spec:
32
32
  type: library
33
33
  lifecycle: production
34
34
  owner: octothorpe
35
+ system: kubernetes-platform
35
36
  dependsOn:
36
37
  - component:invoca-utils-gem
@@ -8,7 +8,7 @@ module KubernetesTemplateRendering
8
8
 
9
9
  attr_reader :groups_to_render, :variables, :template_path, :output_directory, :template_path_exclusions, :group_variable_name
10
10
 
11
- def initialize(template_path:, definitions_path:, variables:, output_directory:, groups_to_render:, template_path_exclusions:, group_variable_name: nil)
11
+ def initialize(template_path:, definitions_path:, variables:, output_directory:, groups_to_render:, template_path_exclusions:, group_variable_name: nil, variable_overrides: {}, source_repo: nil)
12
12
  @template_path = template_path
13
13
  @definitions_path = definitions_path
14
14
  @variables = variables
@@ -16,6 +16,8 @@ module KubernetesTemplateRendering
16
16
  @groups_to_render = groups_to_render
17
17
  @template_path_exclusions = template_path_exclusions || {}
18
18
  @group_variable_name = group_variable_name || DEFAULT_GROUP_VARIABLE_NAME
19
+ @variable_overrides = variable_overrides
20
+ @source_repo = source_repo
19
21
  end
20
22
 
21
23
  def render(args)
@@ -28,7 +30,7 @@ module KubernetesTemplateRendering
28
30
  else
29
31
  vars = variables.merge(group_variable_name => deploy_group)
30
32
  filename = filename_for_deploy_group(deploy_group)
31
- Resource.new(template_path: template_path, definitions_path: @definitions_path, variables: vars, output_directory: output_directory, output_filename: filename).tap do |resource|
33
+ Resource.new(template_path: template_path, definitions_path: @definitions_path, variables: vars, output_directory: output_directory, output_filename: filename, variable_overrides: @variable_overrides, source_repo: @source_repo).tap do |resource|
32
34
  resource.render(args) if args.render_files?
33
35
  end
34
36
  end
@@ -74,12 +74,13 @@ module KubernetesTemplateRendering
74
74
 
75
75
  # Bounded reconcile scope roots for this entry, one per region × color.
76
76
  #
77
- # The sweep root is the parent directory of the entry's rendered `output_directory`, derived
78
- # from the actual `directory:` pattern rather than assuming a fixed layout. For a
79
- # `.../<service>` pattern that parent is the `<region>/<cluster_type>/<color>` base; for a
80
- # `<region>/<service>` pattern it is `<region>`. The parent is shared with sibling entries, so
81
- # leftovers from a deleted/renamed entry under it are swept. The renderer validates each
82
- # `base_root` stays within `rendered_directory` (out-of-prefix, full or relative, is a hard error).
77
+ # The sweep root is the entry's canonical base `<region>/<cluster_type>/<color>` for a non-SPP
78
+ # entry, or `<region>/<cluster_type>/<color>/spp/SPP-PLACEHOLDER` for an SPP one independent of
79
+ # how deep the `subdirectory:` nests. Anchoring at the canonical base (rather than the rendered
80
+ # `output_directory`'s parent) keeps the sweep root fixed when a `subdirectory:` is renamed or
81
+ # nested deeper, so leftovers at the old shallower path are still swept. The renderer validates
82
+ # that the `output_directory` actually falls within this root before sweeping (an entry that
83
+ # renders elsewhere — only reachable via the deprecated `directory:` field — is a hard error).
83
84
  #
84
85
  # Each scope also carries `spp:` (whether this entry is an SPP definition) and `spp_base_root:`
85
86
  # (the canonical `<region>/<cluster_type>/<color>/spp/SPP-PLACEHOLDER` prefix for that region ×
@@ -88,8 +89,10 @@ module KubernetesTemplateRendering
88
89
  @regions.flat_map do |plain_region|
89
90
  @colors.map do |c|
90
91
  output_directory = File.join(@rendered_directory, format(@target_output_directory, plain_region: plain_region, color: c, type: @kubernetes_cluster_type))
92
+ base_path = File.join(@rendered_directory, format(BASE_OUTPUT_DIRECTORY, plain_region: plain_region, color: c, type: @kubernetes_cluster_type))
91
93
  spp_base_root = File.join(@rendered_directory, format(SPP_BASE_OUTPUT_DIRECTORY, plain_region: plain_region, color: c, type: @kubernetes_cluster_type))
92
- { base_root: File.dirname(output_directory), output_directory: output_directory, spp: @spp, spp_base_root: spp_base_root }
94
+ base_root = @spp ? spp_base_root : base_path
95
+ { base_root: base_root, output_directory: output_directory, spp: @spp, spp_base_root: spp_base_root }
93
96
  end
94
97
  end
95
98
  end
@@ -293,7 +296,9 @@ module KubernetesTemplateRendering
293
296
  output_directory: output_directory,
294
297
  groups_to_render: deploy_groups_to_render,
295
298
  template_path_exclusions: deploy_group_config["exclude_files"],
296
- group_variable_name: deploy_group_config["variable_name"]
299
+ group_variable_name: deploy_group_config["variable_name"],
300
+ variable_overrides: variable_overrides,
301
+ source_repo: source_repo
297
302
  )
298
303
  end
299
304
  end
@@ -92,6 +92,11 @@ module KubernetesTemplateRendering
92
92
  scopes.each do |scope|
93
93
  validate_within_scope!(scope[:base_root], @rendered_directory)
94
94
  validate_spp_layout!(scope)
95
+ # Every entry must render within its canonical root so reconcile owns exactly what it sweeps.
96
+ # SPP entries are already constrained to the spp/SPP-PLACEHOLDER prefix by validate_spp_layout!;
97
+ # a non-SPP entry can only escape its base via the deprecated `directory:` field, which reconcile
98
+ # cannot own — so reject it before any writes rather than sweep a tree it does not render into.
99
+ validate_within_scope!(scope[:output_directory], scope[:base_root]) unless scope[:spp]
95
100
  end
96
101
 
97
102
  base_roots = []
@@ -142,7 +147,8 @@ module KubernetesTemplateRendering
142
147
  # is always re-rendered (it is the expansion source) and each target is freshly expanded from it,
143
148
  # so both are marker-safe. Unrequested SPP siblings are not re-rendered this run and stay excluded.
144
149
  def spp_reconcile_roots(scope)
145
- root = spp_sweep_root(scope)
150
+ # base_root is the canonical `.../spp/SPP-PLACEHOLDER` prefix for SPP entries.
151
+ root = scope[:base_root]
146
152
  return [root] if @spps.empty?
147
153
  return [root] unless root.include?(ResourceSet::SPP_PLACEHOLDER)
148
154
 
@@ -153,13 +159,6 @@ module KubernetesTemplateRendering
153
159
  Pathname.new(root).relative_path_from(Pathname.new(@rendered_directory)).each_filename.include?(SPP_FENCE_DIRNAME)
154
160
  end
155
161
 
156
- # When the directory pattern has no service subdirectory (e.g. `.../spp/SPP-PLACEHOLDER`),
157
- # base_root lands at the `spp/` level itself — sweeping that would touch all SPP siblings.
158
- # Use output_directory (= `spp/<spp-name>`) in that case instead.
159
- def spp_sweep_root(scope)
160
- File.basename(scope[:base_root]) == SPP_FENCE_DIRNAME ? scope[:output_directory] : scope[:base_root]
161
- end
162
-
163
162
  def reconcile_sweep(reconciler, scopes)
164
163
  scopes[:base_roots].each { |r| reconciler.sweep!(root: r, fences: [File.join(r, SPP_FENCE_DIRNAME)]) }
165
164
  scopes[:spp_roots].each { |r| reconciler.sweep!(root: r) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesTemplateRendering
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes_template_rendering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Octothorpe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-07-07 00:00:00.000000000 Z
11
+ date: 2026-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport