helmfile/pkg/state
Philipp Hossner 85accf7330
Add helm-secrets-encrypted values template file (#1701)
Secret files ending with .gotmpl are now also rendered as a gotemplate.

```
releases:
- name: myapp
  secrets:
  - secrets.yaml.gotmpl
```

Note that currently, .gotmpl files must be valid YAML files as well.

The expected use-case of this feature is to compose a YAML array from values and encrypted secrets.

Without this feature, you would have tried to do something like the below, which didn't work.

**Example (doesn't work!)**

`values.yaml.gotmpl`:

```
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
```

`secrets.yaml`:
```
_sops:
  #...
environment:
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  values:
  - values.yaml
  secrets:
  - secrets.yaml
```

This doesn't work because `values.yaml` and the decrypted `secrets.yaml` are passed to `helm` to be merged, and helm overrides the array instead of merging or concatenating the arrays.

**Example (works!)**

Instead of `values.yaml` and `secrets.yaml`, you provide a single `secrets.yaml.gotmpl` that is a valid YAML and encrypted by sops:

```
_sops:
  #...
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  secrets:
  - secrets.yaml.gotmpl
```

Helmfile decrypts the gotmpl by handing it over to helm-secrets and then renders the result as a gotmpl file. The end result is that you have a two-element array `environments` that can be just passed to helm.

Resolves #1700

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2021-04-06 14:20:42 +09:00
..
testdata Add regression tests for environment values merge (#1170) 2020-04-04 14:27:29 +09:00
chart_dependency.go Improve error message on deps resolution error (#1727) 2021-03-23 16:44:59 +09:00
create.go Fix/secrets ordering (#1726) 2021-03-23 18:00:57 +09:00
create_test.go Fix the logic of helmfile deps and add tests. (#1588) 2020-11-19 09:29:59 +09:00
environment.go Add support for kubeContext in environments (#1675) 2021-03-23 18:06:53 +09:00
envvals_loader.go Add the ability to load a remote environment values file (#1296) 2020-06-11 10:04:01 +09:00
envvals_loader_test.go Add the ability to load a remote environment values file (#1296) 2020-06-11 10:04:01 +09:00
helmx.go Fix error on concurrent go-getter on same URL (#1669) 2021-02-05 09:02:21 +09:00
release.go feat: `helmfile build --embed-values` to embed release values and secrets into the output (#1436) 2020-08-29 13:18:17 +09:00
release_error.go Fix misleading `helmfile diff` output (#1174) 2020-04-04 17:39:20 +09:00
release_filters.go Treat selector with multiple conditions an AND (#1478) 2020-09-15 09:56:05 +09:00
selector_test.go Fix concurrent-map-iteration-and-write errors while running release hooks (#1534) 2020-10-13 14:49:01 +09:00
state.go Add helm-secrets-encrypted values template file (#1701) 2021-04-06 14:20:42 +09:00
state_exec_tmpl.go feat: Allow overriding chart via flag (#1751) 2021-04-06 13:20:41 +09:00
state_exec_tmpl_test.go Fix concurrent-map-iteration-and-write errors while running release hooks (#1534) 2020-10-13 14:49:01 +09:00
state_gogetter_test.go Fix error on concurrent go-getter on same URL (#1669) 2021-02-05 09:02:21 +09:00
state_run.go feat: GA of Kustomize and K8s manifests support (#1172) 2020-05-27 11:42:43 +09:00
state_test.go feat: --show-secrets on diff and apply commands (#1749) 2021-04-01 09:41:53 +09:00
storage.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
temp.go feat: Stabilize helmfile-diff output (#1622) 2020-12-15 10:24:27 +09:00
temp_rand.go feat: Stabilize helmfile-diff output (#1622) 2020-12-15 10:24:27 +09:00
temp_test.go Add helmfile-fetch command to downloading and generating charts (#1734) 2021-03-30 16:26:31 +09:00
types.go feat: Allow overriding chart via flag (#1751) 2021-04-06 13:20:41 +09:00
util.go Add support for ChartCenter (#1492) 2020-09-21 15:31:24 +09:00
util_test.go Add support for ChartCenter (#1492) 2020-09-21 15:31:24 +09:00