Skip to content

test: add integration test for selector filtering with requiredEnv (#1172) - #2678

Merged
yxxhero merged 2 commits into
helmfile:mainfrom
yxxhero:fix/selector-lenient-requiredenv-1172
Jun 30, 2026
Merged

yxxhero merged 2 commits into
helmfile:mainfrom
yxxhero:fix/selector-lenient-requiredenv-1172

Conversation

@yxxhero

@yxxhero yxxhero commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Add integration test verifying that selector-based filtering (-l/--selector) works correctly when requiredEnv is used in release values.

Closes #1172.

Context

The entire helmfile document is rendered as a Go template before selectors filter releases. This is by design — users set all required environment variables, rendering succeeds, and selectors then correctly filter which releases are processed.

This test confirms that the existing selector filtering works correctly end-to-end:

Scenario Expected
helmfile template -l tier=label2 Only rel2 templated; rel1 excluded
helmfile template (no selector) Both rel1 and rel2 templated

Test

test/integration/test-cases/issue-1172-selector-required-env/
  input/
    helmfile.yaml.gotmpl    # two releases with labels + requiredEnv
issue-1172-selector-required-env.sh

The helmfile has two releases with different tier labels. rel1 uses requiredEnv "ISSUE_1172_BUZZ" in its values. The test sets the env var, then verifies selector filtering.

aditmeno
aditmeno previously approved these changes Jun 30, 2026
…ve (helmfile#1172)

The entire helmfile document is rendered as a Go template before selector
labels filter releases. This means requiredEnv calls in releases excluded
by selectors still fail, blocking the whole run.

When selectors are active and rendering fails due to a requiredEnv error,
helmfile now retries with lenient mode: unset env vars produce empty
strings instead of failing. The document can then be parsed and filtered
by selectors normally.

Behavior:
- Without selectors: requiredEnv fails as before (validation preserved)
- With selectors, all env vars set: strict render succeeds, no retry
- With selectors, some env vars missing: lenient retry, excluded releases
  get empty values and are filtered out by selectors

Implementation:
- Add RequiredEnvError type + ErrRequiredEnvNotSet sentinel for type-safe
  error detection via errors.As
- Add lenientRequiredEnv flag to tmpl.Context; requiredEnv returns empty
  string instead of failing when set
- Add NewLenientFileRenderer via functional options pattern
  (FileRendererOption / WithPreRender / WithLenientRequiredEnv)
- Extract renderWithSelectorFallback in two_pass_renderer.go
- Pass selectors from LoadOpts to desiredStateLoader

Closes helmfile#1172

Signed-off-by: yxxhero <[email protected]>
Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the fix/selector-lenient-requiredenv-1172 branch from 253ef8b to 5ef993d Compare June 30, 2026 00:22
…elmfile#1172)

Verify that selector-based filtering works correctly when requiredEnv is
used in release values. Users set all required env vars, so rendering
succeeds, and selectors filter out non-matching releases.

Test scenarios:
- helmfile template -l tier=label2: only rel2 is templated (rel1 excluded)
- helmfile template without selector: both releases are templated

Closes helmfile#1172

Signed-off-by: yxxhero <[email protected]>
Signed-off-by: yxxhero <[email protected]>
@yxxhero yxxhero changed the title fix: retry rendering with lenient requiredEnv when selectors are active test: add integration test for selector filtering with requiredEnv (#1172) Jun 30, 2026
@yxxhero

yxxhero commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@aditmeno

@yxxhero
yxxhero merged commit 365afc0 into helmfile:main Jun 30, 2026
16 checks passed
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Jul 10, 2026
…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 [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2664](helmfile/helmfile#2664)
- fix: ensure OCI charts are prepared for needed releases with --include-needs by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2663](helmfile/helmfile#2663)
- fix: serialize concurrent helm operations for same chart to fix [#&#8203;768](helmfile/helmfile#768) by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2662](helmfile/helmfile#2662)
- fix: clean up chartify temp directories after helm operations by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2668](helmfile/helmfile#2668)
- feat: add --template-args flag to template/apply/sync for helm lookup() support by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2666](helmfile/helmfile#2666)
- fix: support go-getter URLs in ad-hoc dependencies to fix [#&#8203;821](helmfile/helmfile#821) by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2670](helmfile/helmfile#2670)
- test: add integration test for issue [#&#8203;1880](helmfile/helmfile#1880) transformers with file:// deps by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2673](helmfile/helmfile#2673)
- fix: replace YAML-based DeepCopy with recursive deep copy to fix [#&#8203;973](helmfile/helmfile#973) by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2675](helmfile/helmfile#2675)
- build(deps): bump github.com/helmfile/vals from 0.44.2 to 0.44.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2677](helmfile/helmfile#2677)
- test: add integration test for selector filtering with requiredEnv ([#&#8203;1172](helmfile/helmfile#1172)) by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2678](helmfile/helmfile#2678)
- build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.25 to 1.32.26 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;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 [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2682](helmfile/helmfile#2682)
- feat: add `inherits:` for sub-helmfile config inheritance by [@&#8203;yxxhero](https://github.com/yxxhero) in [#&#8203;2680](helmfile/helmfile#2680)
- feat: Add ConditionTemplate support in releaseSpec by [@&#8203;agarov](https://github.com/agarov) in [#&#8203;2669](helmfile/helmfile#2669)
- build(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.32.26 to 1.32.27 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;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 [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2685](helmfile/helmfile#2685)
- build(deps): bump github.com/helmfile/vals from 0.44.3 to 0.44.4 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2686](helmfile/helmfile#2686)

#### New Contributors

- [@&#8203;agarov](https://github.com/agarov) made their first contribution in [#&#8203;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
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helmfile renders entire helmfile even with selector labels

3 participants