Repository navigation
Fix | Redirect sources defined in ApplicationSet spec.templatePatch - #518
Open
anthonyhaussman wants to merge 1 commit into
Open
anthonyhaussman wants to merge 1 commit into
anthonyhaussman wants to merge 1 commit into
Conversation
ApplicationSets defining sources in spec.templatePatch were never redirected, so base and target renders were identical and the diff was empty. Assisted-by: Claude Opus 5.5
Owner
|
@anthonyhaussman Thanks for catching this! I’d suggest letting Argo CD generate the Applications first, then reusing our existing source redirection logic. That means generating some unchanged ApplicationSets we could otherwise skip, but it avoids guessing what the template will produce. If you want a contribution please feel free to steal the code and update your PR. |
This branch has not been deployed
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.
Problem
RedirectSourcesonly rewritestargetRevisionunderspec.template.spec.source(s)of an ApplicationSet. When the sources are defined inspec.templatePatch(a Go-template string, often required for conditional sources such as{{- if eq (index .metadata.labels "env") "prod" }}), they are never redirected to the PR branch.As a result, the base and target ApplicationSets are identical, they are dropped as
identical copy, and the tool reports no changes even when the referenced chart or values changed.Fix
RedirectSourcesnow also processesspec.templatePatch:{{- if }},{{ .name }}, ...) are kept untouched and the patch does not need to be valid YAML.targetRevision:key, sibling keys of the same mapping (repoURL,chart) are collected and passed to the existingredirectSourceMap, so the repo selector and--redirect-target-revisionsbehave exactly as for regular sources.values: |) are ignored; no key is inserted whentargetRevisionis absent.Tests
pkg/argoapplication/patching_templatepatch_test.gocovering: multiple sources inside an{{- if }}block with chart and foreign-repo sources, key ordering / quoting / trailing comments,redirectRevisionsfiltering, and block scalars.make run-unit-testsandgolangci-lint run ./...pass.docs/how-it-works.mdupdated.