Add docs on how to assign arrays with toolbox template

This commit is contained in:
Peter Rifel 2021-11-06 09:29:35 -04:00
parent f49b99fcf9
commit 3c7b4c7f07
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
1 changed files with 21 additions and 0 deletions

View File

@ -146,6 +146,27 @@ maxSize: {{ '{{ default "10" $node.max_size }}' }}
minSize: {{ '{{ default "1" $node.min_size }}' }}
```
Assigning entire arrays is also supported with Sprig's [toJson function](https://masterminds.github.io/sprig/defaults.html).
```yaml
# template
spec:
kubernetesApiAccess: {{ '{{.allowedIPs | toJson }}' }}
```
```yaml
# values
allowedIPs:
- 1.2.3.4/32
- 4.3.2.1/32
```
```yaml
# rendered
spec:
kubernetesApiAccess: ["1.2.3.4/32","4.3.2.1/32"]
```
### Formatting
Formatting in golang templates is a pain! At the start or at the end of a statement can be infuriating to get right, so a `--format-yaml=true` *(defaults to false)* command line option has been added. This will first unmarshal the generated content *(performing a syntax verification)* and then marshal back the content removing all those nasty formatting issues, newlines etc.