fix: resolve cross-document YAML anchors broken by Helm v4 post-render#4978
Open
JeffResc wants to merge 3 commits into
Open
fix: resolve cross-document YAML anchors broken by Helm v4 post-render#4978JeffResc wants to merge 3 commits into
JeffResc wants to merge 3 commits into
Conversation
✅ Deploy Preview for zarf-docs canceled.
|
zarf-dev#4977) Signed-off-by: Jeff Rescignano <jeffr@defenseunicorns.com>
37ecab9 to
2141c99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Deploying a chart that renders a
kind: Listwhose items share a YAML anchor fails post-render withunknown anchor 'shared' referenced. Plainhelm installof the same chart succeeds.Root cause (upstream Helm)
The defect is in Helm v4, not Zarf. Helm runs
annotateAndMergeonly when a post-renderer is set (Zarf always sets one), and it round-trips manifests through kustomizekio, which flattens akind: Listinto separate documents while keeping anchor text, leaving an alias that crosses item boundaries dangling across documents. Fix proposed upstream in helm/helm#32204.What this PR does
Adds a contained, removable stopgap in
getTemplatedManifests, whenSortManifestsfails, it resolves YAML anchors across the whole manifest stream (inlining cross-document aliases so each document is self-contained) and retries once. It is gated on failure, so working charts are byte-for-byte unchanged. The helper usesgoccy/go-yaml, already a Zarf dependency.This mirrors how Zarf already keeps post-render workarounds in its own code (e.g. namespace handling). The stopgap is tagged for removal in inline comments once a Helm fix is released.
Alternatively, this stopgap can be chosen not to be merged and rather wait for the upstream Helm release, but the tests added in this PR should be helpful in either case as they apply to both the stopgap and the upstream fix.
Tests
TestResolveCrossDocumentAnchors, cross-document mapping alias, sequence alias, and a no-anchor case; each repair case first asserts the unrepaired stream genuinely breaksSortManifests.27-kind-list-anchorpackage +TestKindListAnchordeploying thekind: Listanchor chart and asserting both ConfigMaps resolve todata.key = value.Related Issue
Fixes #4977.
Checklist before merging