Repository navigation
feat: add inherits: for sub-helmfile config inheritance - #2680
Merged
Merged
Conversation
Add an opt-in `inherits:` field to `helmfiles:` entries so a sub-helmfile
can inherit specific configuration categories from its parent:
helmfiles:
- path: myapp.yaml
inherits: [repositories, environments]
Allowed values: repositories, helmDefaults, commonLabels, apiVersions,
kubeVersion, templates, environments. Child values win; parent fills gaps
(consistent with `bases:`). This directly fixes #1495, where a repository
declared in the parent was unavailable to sub-helmfiles, producing a
confusing "repo not found" error.
Implementation notes:
- The 6 pure fields (repositories, helmDefaults, commonLabels, apiVersions,
kubeVersion, templates) are merged post-load via MergeInherited; verified
all are consumed post-load (ExecuteTemplates/converge), never at parse.
- environments is injected pre-load as ctxEnv, because RenderedValues is
baked at load time; the parent's resolved values become the base and the
child's own environments: block overrides per key.
- helmDefaults uses a *HelmSpec pointer (value type is non-comparable) with
a no-override mergo merge, so a child that omits helmDefaults inherits the
parent's fully.
- A footgun warning (WarnUninheritedRepos) suggests
`inherits: [repositories]` when a release references a repo the parent
declares but the child lacks.
- Unknown inherits keys are rejected at parse time with the allowed set.
Inheritance is opt-in and fully backward compatible: empty (the default)
preserves the historical independent-sub-helmfile behavior.
Fixes #1495
Signed-off-by: yxxhero <[email protected]>
yxxhero
requested review from
aditmeno,
itscaro,
mumoshu,
xiaomudk and
zhaque44
as code owners
June 30, 2026 14:39
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in inherits: field to helmfiles: entries so sub-helmfiles can inherit selected configuration categories from their parent helmfile, addressing the “repo not found” footgun reported in #1495 while preserving backward-compatible default behavior.
Changes:
- Introduces
inherits:parsing + validation onSubHelmfileSpec, and implements merge/injection logic for inherited configuration (including pre-load environment value injection). - Adds warnings to guide users when a child release references a repo only defined in the parent but not inherited.
- Adds unit/e2e/integration tests and extends documentation to describe
inherits:semantics and allowed keys.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/integration/test-cases/inherits-subhelmfile/readme | Links the new integration test-case to the motivating issue. |
| test/integration/test-cases/inherits-subhelmfile/input/helmfile-transitive.yaml | Integration fixture for transitive environments inheritance. |
| test/integration/test-cases/inherits-subhelmfile/input/helmfile-inherits.yaml | Integration fixture for repositories inheritance scenario. |
| test/integration/test-cases/inherits-subhelmfile/input/helmfile-env.yaml | Integration fixture for environments inheritance with local chart. |
| test/integration/test-cases/inherits-subhelmfile/input/helmfile-bad-key.yaml | Integration fixture ensuring unknown inherits: keys fail parse-time validation. |
| test/integration/test-cases/inherits-subhelmfile/input/grandchild-transitive.yaml.gotmpl | Integration fixture consuming transitively inherited env value in a templated leaf. |
| test/integration/test-cases/inherits-subhelmfile/input/env-values.yaml | Integration env values used by inheritance scenarios. |
| test/integration/test-cases/inherits-subhelmfile/input/child.yaml | Child fixture referencing a repo without declaring it (requires inheritance). |
| test/integration/test-cases/inherits-subhelmfile/input/child-transitive.yaml | Middle fixture propagating inherited env values to its own child. |
| test/integration/test-cases/inherits-subhelmfile/input/child-env.yaml.gotmpl | Child fixture consuming inherited env values in templates. |
| test/integration/test-cases/inherits-subhelmfile.sh | New integration test runner covering repositories/env/transitive/validation scenarios. |
| test/integration/run.sh | Wires the new integration test-case into the integration test suite. |
| pkg/state/state.go | Adds Inherits to SubHelmfileSpec, YAML marshal/unmarshal support, and parse-time validation. |
| pkg/state/inherits_yaml_test.go | YAML-focused tests for parsing, validation, and marshal round-tripping of inherits:. |
| pkg/state/inherited.go | New implementation of allowed keys, inheritance extraction/merge, and repo footgun warning. |
| pkg/state/inherited_test.go | Unit tests covering per-field merge semantics and warning behavior/guards. |
| pkg/app/load_opts.go | Adds Inherited and ParentRepoNames to the load options passed down the sub-helmfile load path. |
| pkg/app/load_opts_test.go | Tests ensuring LoadOpts.DeepCopy preserves inherited fields and avoids env aliasing. |
| pkg/app/inherits_e2e_test.go | E2E tests validating real load flow behavior: inheritance opt-in, warnings, and env value flow. |
| pkg/app/desired_state_file_loader.go | Injects inherited env pre-load, merges pure inherited fields post-load, and emits the repo warning. |
| pkg/app/app.go | Populates inherited config + parent repo names when processing nested helmfiles. |
| docs/shared-configuration-across-teams.md | Documents inherits: usage, allowed keys, precedence, transitive behavior, and warning. |
- BuildInheritedConfig now deep-copies the pure fields via a YAML round-trip (Env via environment.DeepCopy) so the returned config never aliases the parent state's slices/maps, matching its doc comment. Now returns an error to surface round-trip failures; the call site in processNestedHelmfiles is updated. Added TestBuildInheritedConfig_PureFieldsAreDeepCopied to lock in the no-aliasing guarantee. - Fix the broken `bases:` anchor (#) in shared-configuration-across-teams.md to point to writing-helmfile.md#layering-state-files. Signed-off-by: yxxhero <[email protected]>
Member
Author
|
@aditmeno please rerequest the copilot. |
Comment on lines
+5320
to
+5326
| // validate inherits: entries against the allowed set, failing fast on typos | ||
| // (an unknown key would otherwise silently do nothing) | ||
| for _, key := range hf.Inherits { | ||
| if !IsValidInherit(key) { | ||
| return fmt.Errorf("invalid inherits entry %q for path %q: allowed values are %v", key, hf.Path, AllowedInherits) | ||
| } | ||
| } |
| | Key | What is inherited | | ||
| |-----|-------------------| | ||
| | `repositories` | Parent repository definitions (appended; child entry wins on name conflict). | | ||
| | `helmDefaults` | Parent helm defaults; parent fills the child's unset sub-fields, child's set sub-fields win. | |
…efaults caveat Signed-off-by: yxxhero <[email protected]>
Comment on lines
+14
to
+16
| // AllowedInherits is the single source of truth for the keys accepted by the | ||
| // sub-helmfile `inherits:` field. Validation, docs and tests all reference it. | ||
| var AllowedInherits = []string{ |
Comment on lines
+221
to
+225
| logger.Warnf( | ||
| `release %q references repository %q which is defined in the parent helmfile but not inherited. `+ | ||
| `Add "inherits: [repositories]" to this sub-helmfile entry, or declare the repository here.`, | ||
| rel.Name, repo, | ||
| ) |
Comment on lines
+25
to
+27
| // ParentRepoNames is the list of repository names declared in the parent | ||
| // helmfile. It is used by the "did you mean inherits: [repositories]?" | ||
| // footgun warning (state.WarnUninheritedRepos). |
Comment on lines
+1114
to
+1115
| // Parent repo names are constant across sub-helmfiles; compute once for the | ||
| // "did you mean inherits: [repositories]?" footgun warning. |
…ctive-repo wording Signed-off-by: yxxhero <[email protected]>
xiaomudk
approved these changes
Jul 1, 2026
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 [@​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
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
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.
Summary
Add an opt-in
inherits:field tohelmfiles:entries so a sub-helmfile can inherit specific configuration categories from its parent. This directly fixes #1495, where a repository declared in the parent was unavailable to sub-helmfiles, producing a confusingrepo not founderror.Allowed values:
repositories,helmDefaults,commonLabels,apiVersions,kubeVersion,templates,environments.Precedence: child wins, parent fills gaps — consistent with
bases:.Design notes
inherits:(the default) preserves the historical independent-sub-helmfile behavior. This aligns with helmfile's explicitness philosophy and mirrors the existingselectorsInheritedopt-in pattern.repositories,helmDefaults,commonLabels,apiVersions,kubeVersion,templates) are merged post-load viaMergeInherited. Verified all are consumed post-load (ExecuteTemplates/converge), never at parse time, so a post-load merge is effective.environmentsis injected pre-load asctxEnv, becauseRenderedValuesis baked at load time. The parent's resolved values become the base, and the child's ownenvironments:block overrides per key. (Inheriting the declaration block was rejected due to relative-path resolution ambiguity.)helmDefaultsuses a*HelmSpecpointer (the value type contains slices and is non-comparable) with a no-overridemergomerge, so a child that omitshelmDefaultsinherits the parent's fully.state.WarnUninheritedRepossuggestsinherits: [repositories]when a release references a repo the parent declares but the child lacks — naturally suppressed whenrepositoriesis inherited. It ignoresoci:///relative/bare charts.inherits:keys are rejected at parse time with the allowed set.bases:inherits:bases:repeated in every sub-helmfileThey are complementary.
Touch points (isolated to the load path; converge/apply/release logic unchanged)
pkg/state/inherited.go(new) —AllowedInherits,InheritedConfig,BuildInheritedConfig,MergeInherited,WarnUninheritedRepos, dedup helperspkg/state/state.go—Inheritsfield + Marshal/UnmarshalYAML + parse-time validationpkg/app/load_opts.go—Inherited+ParentRepoNames+ explicitEnvDeepCopypkg/app/app.go— populate inprocessNestedHelmfilespkg/app/desired_state_file_loader.go— pre-loadEnvinjection + post-loadMergeInherited+ warningdocs/shared-configuration-across-teams.md—inherits:sectionTest coverage
pkg/state/inherited_test.go): per-field merge semantics, repositories dedup (child wins),*HelmSpecpath, nil/no-op,WarnUninheritedReposfire/suppress + scheme/relative-path guard.pkg/state/inherits_yaml_test.go): parseinherits, reject unknown keys, accept all allowed keys, marshal round-trip.pkg/app/load_opts_test.go):Inheritedpure fields +Envsurvive and are not aliased;ParentRepoNamespreserved.pkg/app/inherits_e2e_test.go, runs without a cluster): repo not found when using helmfiles #1495 regression (repos flow), opt-in negative case, warning fire/suppress, environments value flow.test/integration/test-cases/inherits-subhelmfile/): 4 scenarios — repositories (realincubator/rawrepo registration), environments (local chart value flow), transitive (parent→child→grandchild), validation (parse error). 3 of 4 are network-free and verified locally.Verification
go build ./...,go vet ./...,golangci-lint run→ 0 issuespkg/state,pkg/app,cmdtest suites greenFixes #1495.