<p>Ultimately i'm trying to get an array of strings e.g. <code>['foo', 'bar']</code> in my js app from my helm config.</p>

<p>./vars/dev/organizations.yaml</p>

<pre><code>...
organizations:
  - 'foo'
  - 'bar'
...
</code></pre>

<p>./templates/configmap.yaml</p>

<pre><code>...
data:
  organizations.yaml: |
    organizations: "{{ toYaml .Values.organizations | indent 4 }}"
...
</code></pre>

<p>./templates/deployment.yaml</p>

<pre><code>...
containers:
    args:
       - "--organizations-config"
       - "/etc/app/cfg/organizations.yaml"
...
</code></pre>

<p>index.js</p>

<pre><code>...
const DEFAULT_ORGANIZATIONS_PATH = './vars/local/organizations.yaml'
const program = require('commander')

program
  .option(
    '--organizations-config &lt;file path&gt;',
    'The path to the organizations config file.', DEFAULT_ORGANIZATIONS_PATH)
  .parse(process.argv)

function readConfigs () {
  return Promise.all(configs.map(path =&gt; {
    return new Promise((resolve, reject) =&gt; {
      fs.readFile(path, (err, data) =&gt; {
        err ? reject(err) : resolve(yaml.safeLoad(data))
      })
    })
  }))
}

readConfigs()
  .then(configs =&gt; {
    let organizationsConfig = configs[3]

    console.log('organizationsConfig = ', organizationsConfig)
    console.log('organizationsConfig.organizations = ', organizationsConfig.organizations)
...
</code></pre>

<p>The output from above is:</p>

<pre><code>organizationsConfig =  { organizations: '    - foo - bar' }
organizationsConfig.organizations =      - foo - bar
</code></pre>

<p>How can I modify my helm config so that <code>organizationsConfig.organizations</code> will be <code>['foo', 'bar']</code></p>

<p>One way to get the output you're looking for is to change:</p>

<pre><code>...
organizations:
  - 'foo'
  - 'bar'
...
</code></pre>

<p>To:</p>

<pre><code>organizations: |
  [ 'foo', 'bar']
</code></pre>

<p>So helm treats it as a single string. We happen to know that it contains array content but helm just thinks it's a string. Then we can set that string directly in the configmap:</p>

<p><code>organizations: {{ .Values.organizations | indent 4 }}</code></p>

<p>What this does is what <a href="https://github.com/helm/charts/blob/ac526fa232ebd07452d46fb0028a82d72cfac4b7/stable/grafana/values.yaml#L162" rel="noreferrer">the grafana chart does</a> in that it forces the user to specify the list in the desired format in the first place. Perhaps you'd prefer to take an array from the helm values and convert it to your desired format, which appears to me to be json format. To do that you could follow the <a href="https://github.com/helm/charts/blob/cbd5e811a44c7bac6226b019f1d1810ef5ee45fa/incubator/vault/templates/configmap.yaml#L12" rel="noreferrer">example of the vault chart</a>. So the configmap line becomes:</p>

<p><code>organizations: {{ .Values.organizations | toJson | indent 4 }}</code></p>

<p>Then the yaml that the user puts in can be as you originally had it i.e. a true yaml array. I tried this and it works but I notice that it gives double-quoted content like <code>["foo","bar"]</code></p>

<p>The other way you can do it is with:</p>

<pre><code>organizations:
  {{- range .Values.organizations }}
    - {{ . }}
  {{- end }}
</code></pre>
