Skip to content

Introduce State Values(Environment Values + Defaulting) #640

@mumoshu

Description

@mumoshu

This is a copy-paste of #361 (comment) for visibility.


We're going to introduce State Values, that should be the foundation for various useful features.

(Note that this isn't a breaking change)


We have a feature request that breaks .Environment.Values if done straightforward #398 (comment)

Alternatively, we can change the term to State Values, and:

  • Make it accessible in the template with .Values(not .Environment.Values)

  • Explicitly note in the documentation that Environment Values is for overriding (State) Values

  • Deprecate .Environment.Values and recommend using .Values.

  • .Values can be overrode with command-line args and environment values files(Question: How to handle global variables across helmfiles #398 (comment))

    # Internally this is an alias of `environments.default.values`
    values:
    - myAPIEndpoint: https://dev.example.com/
       mykey: myvalue
    
    environments:
      production:
        values:
        - myAPIEndpoint: https://prod.example.com/
    

    When --environment production

    • {{ .Environment.Values.mykey }} fails(This preserves the existing behavior)
    • {{ .Values.mykey }} results in myvalue cuz .Values is environments.default.values + environments.production.values
  • It's .Values so the command-line args to set it from k-v pairs would naturally look like helmfile --set KEY=VALUE

  • The command-line args to set it from a file it looks like helmfile --values FILE

  • We recently implemented feat: specify env values from the parent to the nested state #622 but it should be changed. Use helmfiles[].values rather than helmfiles[].environment.values make it similar to its command-line flag variant --values.

    helmfiles:
    - name: sub.helmfile.yaml
      values:
        mykey: myvalue
    
  • helmfile --environment NAME remains as-is. It set's the state's environment name.

  • helmfile --set-envvar NAME=VALUE, helmfile --envvar-set, or helmfile --envvar sets envvars from NAME=VALUE pairs.

  • helmfile --envvars-file FILE, or helmfile --envvars FILE sets environment variables from the FILE

For envvars, I personally prefer the combo of helmfile --envvars-file FILE and helmfile --envvar-set NAME=VALUE, as it seems user-friendly because (1)they naturally collocate in the flags list thati s alphabetically sorted (2) it's harder to confuse with --environment NAME.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions