Skip to content

feat: add inherits: for sub-helmfile config inheritance - #2680

Merged
yxxhero merged 4 commits into
mainfrom
feat/sub-helmfile-inherits
Jul 1, 2026
Merged

yxxhero merged 4 commits into
mainfrom
feat/sub-helmfile-inherits

Conversation

@yxxhero

@yxxhero yxxhero commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Add an opt-in inherits: field to helmfiles: 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 confusing repo not found error.

helmfiles:
- path: myapp.yaml
  inherits: [repositories, environments]

Allowed values: repositories, helmDefaults, commonLabels, apiVersions, kubeVersion, templates, environments.

Precedence: child wins, parent fills gaps — consistent with bases:.

Design notes

  • Opt-in & backward compatible. Empty inherits: (the default) preserves the historical independent-sub-helmfile behavior. This aligns with helmfile's explicitness philosophy and mirrors the existing selectorsInherited opt-in pattern.
  • 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 time, so a post-load merge is effective.
  • 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. (Inheriting the declaration block was rejected due to relative-path resolution ambiguity.)
  • helmDefaults uses a *HelmSpec pointer (the value type contains slices and is non-comparable) with a no-override mergo merge, so a child that omits helmDefaults inherits the parent's fully.
  • Footgun warning: state.WarnUninheritedRepos suggests inherits: [repositories] when a release references a repo the parent declares but the child lacks — naturally suppressed when repositories is inherited. It ignores oci:///relative/bare charts.
  • Validation: unknown inherits: keys are rejected at parse time with the allowed set.
bases: inherits:
Model Pull — each file lists files to merge into itself Push — the parent pushes its config to the child
Where shared config lives Must live in a separate file Can live inline in the parent
Repetition bases: repeated in every sub-helmfile Declared once, per sub-helmfile entry

They 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 helpers
  • pkg/state/state.go — Inherits field + Marshal/UnmarshalYAML + parse-time validation
  • pkg/app/load_opts.go — Inherited + ParentRepoNames + explicit Env DeepCopy
  • pkg/app/app.go — populate in processNestedHelmfiles
  • pkg/app/desired_state_file_loader.go — pre-load Env injection + post-load MergeInherited + warning
  • docs/shared-configuration-across-teams.md — inherits: section

Test coverage

  • Unit (pkg/state/inherited_test.go): per-field merge semantics, repositories dedup (child wins), *HelmSpec path, nil/no-op, WarnUninheritedRepos fire/suppress + scheme/relative-path guard.
  • YAML (pkg/state/inherits_yaml_test.go): parse inherits, reject unknown keys, accept all allowed keys, marshal round-trip.
  • DeepCopy (pkg/app/load_opts_test.go): Inherited pure fields + Env survive and are not aliased; ParentRepoNames preserved.
  • e2e (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.
  • Integration (test/integration/test-cases/inherits-subhelmfile/): 4 scenarios — repositories (real incubator/raw repo 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 issues
  • pkg/state, pkg/app, cmd test suites green

Fixes #1495.

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on SubHelmfileSpec, 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.

Comment thread pkg/state/inherited.go Resolved
- 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]>
@yxxhero

yxxhero commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@aditmeno please rerequest the copilot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comment thread pkg/state/state.go
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. |

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Comment thread pkg/state/inherited.go Outdated
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 thread pkg/state/inherited.go
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 thread pkg/app/load_opts.go Outdated
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 thread pkg/app/app.go Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

@yxxhero
yxxhero merged commit afdb248 into main Jul 1, 2026
17 checks passed
@yxxhero
yxxhero deleted the feat/sub-helmfile-inherits branch July 1, 2026 06:44
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.

repo not found when using helmfiles

3 participants