helmfile/pkg
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
..
app feat: Allow overriding chart via flag (#1751) 2021-04-06 13:20:41 +09:00
argparser Bump sprig to v3.1.0 and mergo 3.11 (#1456) 2020-09-04 09:58:54 +09:00
environment Fix: populate .Values regardless of prestate success (#1202) 2020-04-17 09:18:01 +09:00
event feat: Allow overriding chart via flag (#1751) 2021-04-06 13:20:41 +09:00
exectest feat: added in oci repository flag and added helm methods to pull and export charts (#1629) 2021-01-28 09:02:00 +09:00
helmexec Add helm-secrets-encrypted values template file (#1701) 2021-04-06 14:20:42 +09:00
maputil Add indexed key support to --state-values-set (#1042) 2019-12-17 07:31:42 +09:00
plugins feat(template): added secret template function (#1221) 2020-04-25 21:10:02 +09:00
remote Fix error on concurrent go-getter on same URL (#1669) 2021-02-05 09:02:21 +09:00
state Add helm-secrets-encrypted values template file (#1701) 2021-04-06 14:20:42 +09:00
testhelper Fix the logic of helmfile deps and add tests. (#1588) 2020-11-19 09:29:59 +09:00
tmpl Use ghodss/yaml for yaml marshaling & unmarshaling in template (#1556) 2020-12-13 11:03:20 +09:00