From 3c7b4c7f0770e29f0b105d6d494189e9788e2397 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Sat, 6 Nov 2021 09:29:35 -0400 Subject: [PATCH] Add docs on how to assign arrays with toolbox template --- docs/operations/cluster_template.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/operations/cluster_template.md b/docs/operations/cluster_template.md index ff12ed099e..d51c31dbb5 100644 --- a/docs/operations/cluster_template.md +++ b/docs/operations/cluster_template.md @@ -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.