<p>Let's say I'm creating a helm template in which I want the eventual deployments to be able to execute a command to their liking. For this example, I'll use use the <code>touch</code> command.</p>
<p>In my templates file, I'd write it down like this:</p>
<pre><code>templates.yaml

...
foo:
{{- if .Values.foo.command }}
  exec:
    command: {{ .Values.foo.command }}
{{- end }}

...
</code></pre>
<p>Then following that, I'd have my values file:</p>
<pre><code>values.yaml

...

foo:
  command: [&quot;touch&quot;, &quot;bar.txt&quot;]

...
</code></pre>
<p>When I'm checking the resulting template of the above, the command gets templated as:</p>
<pre><code>foo:
  exec:
    command: [touch bar.txt]
</code></pre>
<p>Thus, there are no quotes/commas in its command. Would this still execute as intended? Or are commas and quotes necessary in order for this to execute.</p>
<p>Thanks!</p>

Jeroen
<p>This will not work as expected.  The output syntax you show is a valid YAML list, but only containing a single shell word, and so it is looking for a command named <code>touch bar.txt</code>, where the space would be part of the filename in <code>/usr/bin</code>.</p>
<p>The Go text/template engine that Helm uses isn't especially aware of YAML.  When you directly write out a value like this, it uses a default formatting that's not especially useful.  Helm has a couple of lightly-documented extensions to write out values in a more useful format.  For your example I might use:</p>
<pre class="lang-yaml prettyprint-override"><code>foo:
{{- with .Values.foo.command }}{{/* like &quot;if&quot;, but also rebinds `.` */}}
  exec:
    command:
{{ toYaml . | indent 6 }}
{{- end }}
</code></pre>
<p>This should write out:</p>
<pre class="lang-yaml prettyprint-override"><code>foo:
  exec:
    command:
      - touch
      - bar.txt
###### note: 6 spaces here matches `indent 6`
</code></pre>
<p>You may be able to fit <code>command: {{ toJson .Values.foo.command }}</code> into a single line.  In either case it may not have the exact formatting that's in the <code>values.yaml</code> file, since Helm parses the YAML at startup time and then writes out the equivalent structure.</p>
