Skip to content

feat: add environments values inheritance#741

Closed
Vince-Chenal wants to merge 1 commit into
helmfile:mainfrom
ContentSquare:add-environments-values-inheritance
Closed

feat: add environments values inheritance#741
Vince-Chenal wants to merge 1 commit into
helmfile:mainfrom
ContentSquare:add-environments-values-inheritance

Conversation

@Vince-Chenal

@Vince-Chenal Vince-Chenal commented Mar 13, 2023

Copy link
Copy Markdown
Contributor

Refers to this discussion: #726

Summary

Allow inheriting values defined in previous values items.
There were some concerns about the risk of introducing a breaking change with this feature.
I added a features field at helmfile root in order to enable this behaviour on a per-helmfile basis and avoid introducing breaking changes.

Default behaviour stays the same with environment values.

Example

features:
- layeredEnvironmentValues

environments:
  default:
    values:
        - values1.yaml
        - values2.yaml.gotmpl <-- variables from values1.yaml are available in there

We added a dedicated test for EnvironmentValuesLoader.

@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from 47c0dc8 to 7b89699 Compare March 14, 2023 08:14
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from 7b89699 to eaff5a1 Compare March 23, 2023 10:02
@stale

stale Bot commented Apr 6, 2023

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Apr 6, 2023
@yxxhero yxxhero added feature in progress and removed wontfix This will not be worked on labels Apr 6, 2023
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from f51532d to 23d4ec7 Compare May 4, 2023 12:40
@Vince-Chenal Vince-Chenal marked this pull request as ready for review May 4, 2023 15:09
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 4 times, most recently from f3a5e66 to ec2a1b0 Compare May 12, 2023 07:22
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 3 times, most recently from 250e323 to 145b4da Compare May 19, 2023 08:31
@hileef

hileef commented May 19, 2023

Copy link
Copy Markdown

Nice ! 💪 @mumoshu , with the additional layeredValues flag to guard against these changes being breaking,
do you think we could potentially include this before moving to a major version ? 🙂

I like this implementation as it looks like a fairly simple way to reduce boilerplate while avoiding exec & loadYAML machinery 🙏

@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from 145b4da to cee650a Compare May 25, 2023 13:02
@mumoshu

mumoshu commented May 27, 2023

Copy link
Copy Markdown
Contributor

@Vince-Chenal @hileef Hey! First of all, this looks awesome! I'm definitely looking forward to merging this with only a few changes described below. Can you confirm?


My motivation for doing that is to make it work in concert with environmentTemplates and inherit feature proposed and discussed in #840 (comment).
Could you two read that thread, and my combined proposal below, and mind giving me feedbacks if any? 🙏

So what I'd like to do before merging this pull request is to change layedValues from a flag to another array of values.yaml files that can co-exist with the existing values so that it plays nicely with the environmentTemplates.

environmentTemplates:
  base:
    values:
    - common-static-values.yaml
    layeredValues:
    - common-dynamic-values-1.yaml
    - common-dynamic-values-2.yaml

environments:
  test:
    inherit:
      template: base
    values:
    - adhoc-static-values.yaml
    layeredValues:
    - adhoc-dynamic-values-1.yaml
    - adhoc-dynamic-values-2.yaml

This will result in the test environment to be:

environments:
  test:
    values:
    # (1) sees empty Values when rendering itself
    - common-static-values.yaml
    # (2) sees empty Values when rendering itself
    - adhoc-static-values.yaml
    layeredValues:
    # (3) sees (1)+(2)
    - common-dynamic-values-1.yaml
    # (4) sees (1)+(2)+(3)
    - common-dynamic-values-2.yaml
    # (5) sees (1)+(2)+(3)+(4)
    - adhoc-dynamic-values-1.yaml
    # (6) sees (1)+(2)+(3)+(4)+(5)
    - adhoc-dynamic-values-2.yaml

This way, we can inject values "before the common layedValues derived from the template, but after all static values" via adhoc-static-values.yaml. In other words, you can now pass inputs to the template-declared adhoc-dynamic-values-*.yaml files.

Not only each layedValues entry can see the latest merged values, the first layeredValues entry should see the values from common-static-values.yaml and adhoc-static-values.yaml for the input passing use-case I've described in the previous paragraph.

All in all, this design would give you all the benefits of environment templates along with layered values. Maximum reusability and DRY. WDYT?

@hileef

hileef commented Jun 1, 2023

Copy link
Copy Markdown

Hello @mumoshu , thanks for the feedback !

I've had a look at #840 and your summary proposal here, IMHO I think it's great 💪
I like that we can maintain the requested features here in a terse way,
while opening the door for supporting even more use cases ;

I'll open a PR targetting this one shortly to add the change you requested,
I'm pretty sure that @Vince-Chenal will be ok with approving it 🙂
Once done, we can probably re-update this PR and request your review for merge once again 🙏

@hileef

hileef commented Jun 8, 2023

Copy link
Copy Markdown

Hello again @mumoshu , it took me a while to have time to spend on this topic,
but we've now updated this PR to propose an implementation for the design as proposed in your above comment 🙂

➡️ could you take a look and let us know if these updated changes fits your expectation ?
cc. @Vince-Chenal keeping you in the loop

@hileef hileef force-pushed the add-environments-values-inheritance branch from 1bec42f to e4bd518 Compare June 17, 2023 12:42
@hileef

hileef commented Jun 17, 2023

Copy link
Copy Markdown

Hello @mumoshu , @yxxhero 👋
We've updated this PR to resolve the remaining conflicts against the main branch just now 🙏

It seems that you haven't had a chance to take a look at its contents yet,
could you let us know if there are things we can do in the meantime to help move this forward ? 🙂

@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from 0c612e1 to b679091 Compare July 18, 2025 08:30
@mumoshu

mumoshu commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Hey everyone! OK then... can we make this a per-helmfile.yaml setting, rather than a runtime flag?

Just a quick guess, but having something like:

globalFeatures:
- layeredEnvironmentValues

in helmfile.yaml would work 🤔

It shouldn't be simple features a.k.a local features because this flag will "persist" down to all the sub-helmfiles processed along the way in its current form, an environment variable.

Or, you don't mind setting this feature flag for every helmfile.yaml you use, naming it like features: would be more appropriate, because it's now a per-helmfile.yaml declarative config.

features:
- layeredEnvironmentValues

It may NOT sound like a backward-compatibility breaker to you, because it breaks only when you enabled this runtime feature, yeah...

However, regardless of how it is called, I'm concerned about the possibility that the same helmfile.yaml can be translated differently depending on a runtime setting of Helmfile, which eliminates the benefit of Helmfile- declarativeness. To retain declarativeness as we enhance our configuration language, built around YAML and Go templates, I'd still say that having a declarative way to change Helmfile's behavior is key.

Thank you very much for your patience @Vince-Chenal, and everyone commented on this long-standing proposal!

I hope you are still around, and my suggestion makes sense to you.

@mumoshu

mumoshu commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

I'll also ping @yxxhero and @zhaque44 on our community Slack too for visibility 👋

@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from b679091 to 57ede2e Compare July 31, 2025 14:34
@Vince-Chenal

Copy link
Copy Markdown
Contributor Author

Hey @mumoshu,
No problem for me about enabling this behavior explicitly.
I just pushed a new version with a features field at helmfile root that allows to enable this feature explicitly by passing layeredEnvironmentValues. Maybe I'm missing some implications with sub-helmfiles or else?

Tell me if that's what you had in mind

@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 3 times, most recently from 94855fb to f6b1611 Compare August 12, 2025 07:14
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 3 times, most recently from 233e1e0 to bf62ed3 Compare August 20, 2025 07:41
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from 1b1a8f0 to e867ba4 Compare August 29, 2025 08:39
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from 54059db to 6de4001 Compare September 9, 2025 08:39
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from 07e9b14 to d37ac4b Compare September 29, 2025 08:08
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from d37ac4b to 68140ea Compare October 13, 2025 07:53
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from 68140ea to c617d4f Compare October 20, 2025 14:44
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch 2 times, most recently from 9a74260 to eb672f4 Compare November 5, 2025 17:25
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from eb672f4 to 4cf7641 Compare November 14, 2025 16:59
@Vince-Chenal Vince-Chenal force-pushed the add-environments-values-inheritance branch from 4cf7641 to 6b096fc Compare November 25, 2025 08:38
@zhaque44

zhaque44 commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

closing this, it is outdated at this point

@zhaque44 zhaque44 closed this Dec 1, 2025
@mattcockrell

Copy link
Copy Markdown

@zhaque44 How is this outdated? Has there been a recent build that enables an equivalent feature?

@Vince-Chenal Vince-Chenal deleted the add-environments-values-inheritance branch January 28, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants