From 604af3f1d2221a2ad49978a9a961f1192dd6cc4d Mon Sep 17 00:00:00 2001 From: Rene Hernandez <7692501+renehernandez@users.noreply.github.com> Date: Sun, 7 Jun 2020 19:10:27 -0400 Subject: [PATCH] Replace getOrNil with get function in documentation (#1268) * New output flag for list command Support output as json Add new formatters file to handle extrac formatting to its own concern New config interface to support list command specification * Fix usage message * Add error handling for formatters * Replace usage of getOrNil with get function * Add nil in get function Co-authored-by: Rene Hernandez Remedios --- README.md | 3 ++- docs/writing-helmfile.md | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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 `