'Using a yaml array with helm template

I have a directory structure representing a Helm chart as follows:

Chart.yaml
values.yaml
templates/
  template.tpl

values.yaml:

foo: ["bar", "baz"]

FOO:
 - BAR
 - BAZ

templates/template.tpl:

thing1: {{ .Values.foo }}
thing2: {{ .Values.FOO }}

Output of running helm template . in this directory. (Helm version v3.6.3)

---
# Source: test/templates/template.tpl
thing1: [bar baz]
thing2: [BAR BAZ]

You can see here that both thing1 and thing2 map to YAML arrays containing one string each, namely the strings "bar baz" and "BAR BAZ".

I would like the items in the array to still be separate stings after templating. But the built-in functions that I have found in the helm template language documentation (like {{ list .Values.foo }}) don't do anything productive.

Can someone point me at how to properly template YAML arrays of strings?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source