Repository navigation
feat: Add ConditionTemplate support in releaseSpec - #2669
Conversation
|
I created this PR in order to resolve #2665. I'm not proficient in Go so any advice is welcome. The main problem was that we currently accept a path and not directly a boolean, so I made this little hack to cast the template result into a string and cast it back as a boolean. This keeps backward compatibility but for sure is not the cleanest. |
Code Review: ConditionTemplate supportOverall this is a clean, well-scoped PR that follows the existing 🔴 Bugs / should fix1. Wrong field name in error message ( The new return nil, fmt.Errorf("failed executing template expressions in release \"%s\".version = \"%s\": %v", r.Name, ts, err)This is a copy-paste from the pre-existing buggy "...in release \"%s\".conditionTemplate = \"%s\": %v"(FWIW, the same typo in the three older blocks is worth a follow-up cleanup.) 🟡 Correctness / design concerns2. Silent discard of In 3. Behavior change in Previously 4. go-yaml treats 🟢 Test gaps5. Dead A
So the field is vestigial and suggests a misunderstanding of the flow. Either remove it, or — better — add tests in 6. Missing coverage
🔵 Nit7. Doc inconsistency
Summary: The core feature is correctly implemented and follows house patterns. Before merge I'd ask for at least #1 (error message) and #5/#6 (test cleanup + precedence/error coverage). #3 deserves a changelog note. The rest are doc/polish. |
Deep review: data-flow, design, and edge casesDid a deeper pass tracing the actual execution paths. Findings below, most-impactful first. 1.
|
|
Hello @yxxhero, I just updated the PR with the following changes :
On the |
fb8df88 to
6c762d2
Compare
yxxhero
left a comment
There was a problem hiding this comment.
Review: feat: Add ConditionTemplate support in releaseSpec
Overall the feature is well-designed and mirrors the existing installedTemplate/waitTemplate/verifyTemplate lifecycle cleanly. The new unit tests pass and golangci-lint is clean. Requesting changes because the PR breaks the pre-existing TestGenerateID suite (see below).
🔴 Blocker — breaks TestGenerateID (CI-failing)
Adding ConditionTemplate *string to ReleaseSpec changes the struct's spew serialization, which feeds the FNV hash in generateValuesID (pkg/state/temp.go:66). As a result the golden hashes hardcoded in pkg/state/temp_test.go are now stale:
go test ./pkg/state/... -run TestGenerateID # FAILS
I reproduced this deterministically on this PR branch; main passes. The 6 want values in temp_test.go need updating:
| Case | Old | New |
|---|---|---|
| baseline (L41) | foo-values-6fcd6fc479 |
foo-values-6765d87f7c |
| different bytes content (L48) | foo-values-6556658b7b |
foo-values-6d7db5f8b |
| different map content (L55) | foo-values-fd86f44b |
foo-values-5c55f66dd |
| different chart (L61) | foo-values-58bdc49774 |
foo-values-7665888bf4 |
| different name (L67) | bar-values-856b998888 |
bar-values-bc6f974bd |
| specific ns (L73) | myns-foo-values-7bdfd95fbd |
myns-foo-values-76f8c7c596 |
(Yes, this golden-hash approach is fragile to any ReleaseSpec field addition — but the update belongs in this PR so make test stays green.)
🟡 Minor — CHANGELOG placement (CHANGELOG.md:3)
The new ### Added block is inserted under ## [1.4.1] - 2026-03-03, which is already shipped (latest release is v1.6.0). It belongs in a new ## [Unreleased] section at the top.
🟡 Minor — stale doc comment (pkg/state/state.go:3357)
This line is now inaccurate:
// If the condition is specified but not in the form 'foo.enabled', it returns an error.
After this PR, true/false literals are not in foo.enabled form yet they no longer error. Worth reconciling with the newly inserted "cast boolean" line above it.
🟢 Nits
setConditionFromBool(pkg/state/state_exec_tmpl.go:51) is a single-use one-liner (r.Condition = fmt.Sprintf("%t", condition)); could be inlined, though harmless.- Grammar: "casted boolean" → "cast boolean" (
castis already past tense). - Like the other
*Templatefields, when bothconditionandconditionTemplateare set, the originalconditionis silently overwritten with no log. Consistent with existing behavior, but alogger.Debugfwould help users debugging precedence.
✅ What's good
- Design parity with the other templated bool fields: render in
ExecuteTemplateExpressions→ resolve to bool inupdateBoolTemplatedValues→ nil out the template field. Precedence (conditionTemplateoverridescondition) is correctly implemented and tested (state_exec_tmpl_test.go:113). - The
release.goerror-message fixes (".version ="→".waitTemplate ="/".installedTemplate ="/".verifyTemplate =") are a welcome drive-by fix for copy-paste bugs. condition: true/falseliteral handling is backward-compatible — it converts a previous hard error ("must be in the form 'foo.enabled'") into valid behavior.strings.ToLowercorrectly handlesTrue/FALSE.- Test coverage is solid: true/false literals, precedence, unresolvable template (
{{ "maybe" }}), and YAML bool unmarshal. golangci-lint: 0 issues;go vet: clean.
f5e0a3b to
34f7f85
Compare
|
@yxxhero I just updated the PR with the required fix on the test and the changelog |
Signed-off-by: Arthur Garreau <[email protected]>
Signed-off-by: Arthur Garreau <[email protected]>
…es for ID generation Signed-off-by: Arthur Garreau <[email protected]>
34f7f85 to
75315a5
Compare
There was a problem hiding this comment.
Deep Review: feat: Add ConditionTemplate support in releaseSpec
Traced the full execution flow: ExecuteTemplateExpressions (release.go) -> convergence loop (state_exec_tmpl.go:117) -> updateBoolTemplatedValues -> ConditionEnabled (state.go:3352). Also verified all caller paths in app.go.
Execution order verified
| Command path | ExecuteTemplates called? |
conditionTemplate effective? |
condition: true/false literal effective? |
|---|---|---|---|
apply / sync / diff / destroy / test |
Yes (app.go:1064) | Yes | Yes |
list (app.go:824-866) |
No | No (falls back to raw condition) |
Yes |
The list command calls ConditionEnabled on raw releases without executing templates — so conditionTemplate alone has no effect there. This is consistent with the pre-existing installedTemplate / waitTemplate / verifyTemplate behavior (they're also ignored by list), so not a regression — but worth a doc note (see inline comment on configuration.md).
Findings
[OK] Convergence loop — ExecuteTemplates iterates up to 6x until reflect.DeepEqual converges. conditionTemplate follows the same render->resolve->nil-out lifecycle as the other *Template fields. Correct.
[OK] Clone() (release.go:227) — YAML marshal/unmarshal round-trip handles *string correctly. No deep-copy issue.
[OK] Boolean literal unmarshaling — condition: true in YAML deserializes to Go string "true" because the field type is string. Verified by TestReleaseSpecConditionUnmarshalsBoolLiteral. strings.ToLower handles True/TRUE/etc.
[OK] Error message fixes — The drive-by fix from ".version =" to the correct field names (".waitTemplate =", ".installedTemplate =", ".verifyTemplate =") is correct and welcome.
[OK] Test coverage — true/false literals, precedence, unresolvable template ({{ "maybe" }}), YAML bool unmarshal, hash updates. Solid.
[Nit] setConditionFromBool — Single-use one-liner; inline suggestion provided.
[Doc] CHANGELOG version gap — Latest git tag is v1.6.0 but CHANGELOG only has up to [1.4.1]. The [Unreleased] placement at the top is structurally correct, but the CHANGELOG is already missing [1.5.x]-[1.6.0] sections (pre-existing, not introduced by this PR).
Verdict
Well-implemented, follows existing patterns correctly, no new bugs introduced. The nit (inline setConditionFromBool) and the doc note (list limitation) are non-blocking.
| @@ -1,3 +1,9 @@ | |||
| ## [Unreleased] | |||
There was a problem hiding this comment.
Note: the latest git tag is v1.6.0 but the CHANGELOG only has sections up to [1.4.1]. The [Unreleased] placement at the top is structurally correct, but sections for [1.5.0]-[1.5.5] and [1.6.0] appear to be missing (pre-existing gap, not introduced by this PR).
Co-authored-by: yxxhero <[email protected]> Signed-off-by: Arthur Garreau <[email protected]>
Co-authored-by: yxxhero <[email protected]> Signed-off-by: Arthur Garreau <[email protected]>
Co-authored-by: yxxhero <[email protected]> Signed-off-by: Arthur Garreau <[email protected]>
6cf2d8e to
65cc930
Compare
|
@yxxhero I just applied your suggestions! |
|
@agarov waitting for the ai reviewing. |
There was a problem hiding this comment.
Pull request overview
This PR extends Helmfile release condition handling by introducing a templated conditionTemplate field (evaluated during template execution) and by allowing condition to be specified as a boolean literal (true/false) in addition to a .enabled values lookup path.
Changes:
- Add
ReleaseSpec.ConditionTemplateand execute/resolve it during release template execution, with the rendered boolean overridingcondition. - Enhance
ConditionEnabledto treatcondition: true/false(including YAML boolean literals) as direct enable/disable signals. - Update docs/changelog and expand unit tests to cover the new behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| skills/helmfile/SKILL.md | Documents condition boolean literal support and adds conditionTemplate. |
| pkg/state/temp_test.go | Updates expected IDs for temp values file hashing tests. |
| pkg/state/state.go | Adds ConditionTemplate to ReleaseSpec and extends ConditionEnabled for literal booleans. |
| pkg/state/state_test.go | Adds tests for literal-boolean condition behavior and YAML unmarshalling. |
| pkg/state/state_exec_tmpl.go | Resolves conditionTemplate to a boolean and applies it to condition. |
| pkg/state/state_exec_tmpl_test.go | Adds template execution tests for conditionTemplate (true/false, precedence, error). |
| pkg/state/release.go | Renders conditionTemplate during release template expression execution and improves related error messages. |
| docs/writing-helmfile.md | Documents conditionTemplate and expanded condition semantics. |
| docs/configuration.md | Adds a dedicated “Condition” section and documents conditionTemplate behavior and precedence. |
| CHANGELOG.md | Notes the new conditionTemplate feature and literal condition support under Unreleased. |
|
@agarov please fix ci issue and AI comments. |
Signed-off-by: Arthur Garreau <[email protected]>
done 👍 |
|
@agarov all is well. go go go! |
…227) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [aqua:helmfile/helmfile](https://github.com/helmfile/helmfile) | minor | `1.6.0` → `1.7.0` | --- ### Release Notes <details> <summary>helmfile/helmfile (aqua:helmfile/helmfile)</summary> ### [`v1.7.0`](https://github.com/helmfile/helmfile/releases/tag/v1.7.0) [Compare Source](helmfile/helmfile@v1.6.0...v1.7.0) #### What's Changed - build(deps): bump azure/setup-helm from 5.0.0 to 5.0.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2664](helmfile/helmfile#2664) - fix: ensure OCI charts are prepared for needed releases with --include-needs by [@​yxxhero](https://github.com/yxxhero) in [#​2663](helmfile/helmfile#2663) - fix: serialize concurrent helm operations for same chart to fix [#​768](helmfile/helmfile#768) by [@​yxxhero](https://github.com/yxxhero) in [#​2662](helmfile/helmfile#2662) - fix: clean up chartify temp directories after helm operations by [@​yxxhero](https://github.com/yxxhero) in [#​2668](helmfile/helmfile#2668) - feat: add --template-args flag to template/apply/sync for helm lookup() support by [@​yxxhero](https://github.com/yxxhero) in [#​2666](helmfile/helmfile#2666) - fix: support go-getter URLs in ad-hoc dependencies to fix [#​821](helmfile/helmfile#821) by [@​yxxhero](https://github.com/yxxhero) in [#​2670](helmfile/helmfile#2670) - test: add integration test for issue [#​1880](helmfile/helmfile#1880) transformers with file:// deps by [@​yxxhero](https://github.com/yxxhero) in [#​2673](helmfile/helmfile#2673) - fix: replace YAML-based DeepCopy with recursive deep copy to fix [#​973](helmfile/helmfile#973) by [@​yxxhero](https://github.com/yxxhero) in [#​2675](helmfile/helmfile#2675) - build(deps): bump github.com/helmfile/vals from 0.44.2 to 0.44.3 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2677](helmfile/helmfile#2677) - test: add integration test for selector filtering with requiredEnv ([#​1172](helmfile/helmfile#1172)) by [@​yxxhero](https://github.com/yxxhero) in [#​2678](helmfile/helmfile#2678) - build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.25 to 1.32.26 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2681](helmfile/helmfile#2681) - build(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.104.0 to 1.104.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2682](helmfile/helmfile#2682) - feat: add `inherits:` for sub-helmfile config inheritance by [@​yxxhero](https://github.com/yxxhero) in [#​2680](helmfile/helmfile#2680) - feat: Add ConditionTemplate support in releaseSpec by [@​agarov](https://github.com/agarov) in [#​2669](helmfile/helmfile#2669) - build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.26 to 1.32.27 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2684](helmfile/helmfile#2684) - build(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.104.1 to 1.104.2 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2685](helmfile/helmfile#2685) - build(deps): bump github.com/helmfile/vals from 0.44.3 to 0.44.4 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​2686](helmfile/helmfile#2686) #### New Contributors - [@​agarov](https://github.com/agarov) made their first contribution in [#​2669](helmfile/helmfile#2669) **Full Changelog**: <helmfile/helmfile@v1.6.0...v1.7.0> </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/London) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL21pbm9yIl19--> Reviewed-on: https://forgejo.hayden.moe/hayden/phoebe/pulls/227
helmfile 1.7.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed * build(deps): bump azure/setup-helm from 5.0.0 to 5.0.1 by @dependabot[bot] in helmfile/helmfile#2664 * fix: ensure OCI charts are prepared for needed releases with --include-needs by @yxxhero in helmfile/helmfile#2663 * fix: serialize concurrent helm operations for same chart to fix #768 by @yxxhero in helmfile/helmfile#2662 * fix: clean up chartify temp directories after helm operations by @yxxhero in helmfile/helmfile#2668 * feat: add --template-args flag to template/apply/sync for helm lookup() support by @yxxhero in helmfile/helmfile#2666 * fix: support go-getter URLs in ad-hoc dependencies to fix #821 by @yxxhero in helmfile/helmfile#2670 * test: add integration test for issue #1880 transformers with file:// deps by @yxxhero in helmfile/helmfile#2673 * fix: replace YAML-based DeepCopy with recursive deep copy to fix #973 by @yxxhero in helmfile/helmfile#2675 * build(deps): bump github.com/helmfile/vals from 0.44.2 to 0.44.3 by @dependabot[bot] in helmfile/helmfile#2677 * test: add integration test for selector filtering with requiredEnv (#1172) by @yxxhero in helmfile/helmfile#2678 * build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.25 to 1.32.26 by @dependabot[bot] in helmfile/helmfile#2681 * build(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.104.0 to 1.104.1 by @dependabot[bot] in helmfile/helmfile#2682 * feat: add `inherits:` for sub-helmfile config inheritance by @yxxhero in helmfile/helmfile#2680 * feat: Add ConditionTemplate support in releaseSpec by @agarov in helmfile/helmfile#2669 * build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.26 to 1.32.27 by @dependabot[bot] in helmfile/helmfile#2684 * build(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.104.1 to 1.104.2 by @dependabot[bot] in helmfile/helmfile#2685 * build(deps): bump github.com/helmfile/vals from 0.44.3 to 0.44.4 by @dependabot[bot] in helmfile/helmfile#2686 ## New Contributors * @agarov made their first contribution in helmfile/helmfile#2669 **Full Changelog**: https://github.com/helmfile/helmfile/compare/v1.6.0...v1.7.0</pre> <p>View the full release notes at <a href="https://github.com/helmfile/helmfile/releases/tag/v1.7.0">https://github.com/helmfile/helmfile/releases/tag/v1.7.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!13508
This pull request adds support for a new
conditionTemplatefield for Helmfile releases, allowing users to specify dynamic, templated conditions for enabling or disabling releases. It also improves the handling of theconditionfield to accept boolean literals (true/false) directly, and updates documentation and tests to reflect these enhancements.New Features:
conditionTemplatefield inReleaseSpec, which allows release conditions to be specified as Go templates that must render to a boolean. If set,conditionTemplatetakes precedence overcondition[1] [2] [3] [4].conditionTemplatein the release templating logic, converting the rendered result to a boolean and updating the release'sconditionaccordingly [1] [2].Improvements to Condition Handling:
conditionfield to directly accept boolean literals (true/false) in addition to value lookups, simplifying configuration for static conditions [1] [2] [3].Documentation Updates:
conditionTemplatefield, its precedence, and the expanded capabilities of theconditionfield [1] [2] [3] [4].Testing:
conditionTemplateand the new boolean literal handling forcondition[1] [2] [3] [4].