Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce State Values(Environment Values + Defaulting) #640

Closed
mumoshu opened this issue Jun 3, 2019 · 3 comments · Fixed by #647
Closed

Introduce State Values(Environment Values + Defaulting) #640

mumoshu opened this issue Jun 3, 2019 · 3 comments · Fixed by #647

Comments

@mumoshu
Copy link
Collaborator

mumoshu commented Jun 3, 2019

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.

mumoshu added a commit that referenced this issue Jun 4, 2019
The addition of `--set k1=v1,k2=v2` and `--values file1 --values file2` was originally planned in #361.

But it turned out we already had `--values` for existing helmfile commands like `sync`. Duplicated flags doesn't work, obviously.

So this actually add `--state-values-set k1=v1,k2=v2` and `--set-values-file file1 --set-values-file file2`.

They are called "state" values according to the discussion we had at #640

Resolevs #361
mumoshu added a commit that referenced this issue Jun 4, 2019
The addition of `--set k1=v1,k2=v2` and `--values file1 --values file2` was originally planned in #361.

But it turned out we already had `--values` for existing helmfile commands like `sync`. Duplicated flags doesn't work, obviously.

So this actually add `--state-values-set k1=v1,k2=v2` and `--set-values-file file1 --set-values-file file2`.

They are called "state" values according to the discussion we had at #640

Resolves #361
mumoshu added a commit that referenced this issue Jun 4, 2019
#644)

The addition of `--set k1=v1,k2=v2` and `--values file1 --values file2` was originally planned in #361.

But it turned out we already had `--values` for existing helmfile commands like `sync`. Duplicated flags doesn't work, obviously.

So this actually add `--state-values-set k1=v1,k2=v2` and `--set-values-file file1 --set-values-file file2`.

They are called "state" values according to the discussion we had at #640

Resolves #361
mumoshu added a commit that referenced this issue Jun 4, 2019
This adds `values` to state files as proposed in #640.

```yaml
values:
- key1: val1
- defaults.yaml

environments:
  default:
  - values:
    - environments/default.yaml
  production:
  - values:
    - environments/production.yaml

```

Resolves #640
mumoshu added a commit that referenced this issue Jun 4, 2019
This adds `values` to state files as proposed in #640.

```yaml
values:
- key1: val1
- defaults.yaml

environments:
  default:
  - values:
    - environments/default.yaml
  production:
  - values:
    - environments/production.yaml

```

Resolves #640
@mumoshu
Copy link
Collaborator Author

mumoshu commented Jun 4, 2019

helmfile --values FILE has been implemented as helmfile --state-values-file FILE and helmfile --set key=val as helmfile --state-values-file-set to avoid collision with the existing --values FILE flag of helmfile sync. See #644

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jun 4, 2019

values: is being added to the state file syntax and .Values is being added to the template syntax via #647

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jun 4, 2019

Please file another feature requests for adding helmfile ability to set envvars via command-line flags.

mumoshu added a commit that referenced this issue Jun 4, 2019
This adds `values` to state files as proposed in #640.

```yaml
values:
- key1: val1
- defaults.yaml

environments:
  default:
  - values:
    - environments/default.yaml
  production:
  - values:
    - environments/production.yaml

```

Resolves #640
mumoshu added a commit that referenced this issue Jun 4, 2019
This adds `values` to state files as proposed in #640.

```yaml
values:
- key1: val1
- defaults.yaml

environments:
  default:
  - values:
    - environments/default.yaml
  production:
  - values:
    - environments/production.yaml

```

`{{ .Valuese.key1 }}` evaluates to `val1` if and only if it is not overrode via the production or the default env, or command-line args.

Resolves #640
mumoshu added a commit that referenced this issue Jun 4, 2019
This adds `values` to state files as proposed in #640.

```yaml
values:
- key1: val1
- defaults.yaml

environments:
  default:
  - values:
    - environments/default.yaml
  production:
  - values:
    - environments/production.yaml

```

`{{ .Valuese.key1 }}` evaluates to `val1` if and only if it is not overrode via the production or the default env, or command-line args.

Resolves #640
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 a pull request may close this issue.

1 participant