diff --git a/README.md b/README.md index ba56b3f4..47c9ab12 100644 --- a/README.md +++ b/README.md @@ -532,6 +532,7 @@ In addition to built-in ones, the following custom template functions are availa - `fromYaml` reads a golang string and generates a map - `setValueAtPath PATH NEW_VALUE` traverses a golang map, replaces the value at the PATH with NEW_VALUE - `toYaml` marshals a map into a string +- `get` returns the value of the specified key if present in the `.Values` object, otherwise will return the default value defined in the function ### Values Files Templates @@ -671,7 +672,7 @@ releaseName: prod `values.yaml.gotmpl` ```yaml -domain: {{ .Values | getOrNil "my.domain" | default "dev.example.com" }} +domain: {{ .Values | get "my.domain" "dev.example.com" }} ``` `helmfile sync` installs `myapp` with the value `domain=dev.example.com`, diff --git a/docs/writing-helmfile.md b/docs/writing-helmfile.md index 792785e0..4846bd9b 100644 --- a/docs/writing-helmfile.md +++ b/docs/writing-helmfile.md @@ -14,10 +14,10 @@ That is, the following example let `helmfile` fail when you have no `eventApi.re {{ .Values.eventApi.replicas | default 1 }} ``` -In case it isn't a mistake and you do want to allow missing keys, use the `getOrNil` template function: +In case it isn't a mistake and you do want to allow missing keys, use the `get` template function: ``` -{{ .Values | getOrNil "eventApi.replicas" }} +{{ .Values | get "eventApi.replicas" nil }} ``` This result in printing `