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 <rene.hernandez@fullscript.com>
This commit is contained in:
Rene Hernandez 2020-06-07 19:10:27 -04:00 committed by GitHub
parent 28e13c3a18
commit 604af3f1d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -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`,

View File

@ -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 `<no value` in your template, that may or may not result in a failure.
@ -25,7 +25,7 @@ This result in printing `<no value` in your template, that may or may not result
If you want a kind of default values that is used when a missing key was referenced, use `default` like:
```
{{ .Values | getOrNil "eventApi.replicas" | default 1 }}
{{ .Values | get "eventApi.replicas" 1 }}
```
Now, you get `1` when there is no `eventApi.replicas` defined in environment values.