title: Convert a YAML to string in Helm
body: <p>I have an helm chart used to deploy an application that have configuration file in YAML format.
  Currently, my helm chart use the following code:</p>
  
  <p><em>values.yaml</em></p>
  
  <pre class="lang-yaml prettyprint-override"><code>databaseUser: "dbuser"
  
  configFiles:
    db_config_file.yaml: |-
      databaseUser: {{ .Values.databaseUser }}
      databasePort: 1234
      [...]
  
  [...]
  </code></pre>
  
  <p><strong>templates/configmap.yaml</strong></p>
  
  <pre class="lang-yaml prettyprint-override"><code>data:
    {{- range $name, $config := .Values.configFiles }}
    {{ $name }}: |-
  {{ tpl $config $ | indent 4 }}
    {{- end }}
  </code></pre>
  
  <p>This code allow me to change easily the <code>databaseUser</code> from values, but the problem is that if I want to change the value of <code>databasePort</code>, I have to rewrite the entire configuration like that:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>configFiles:
    db_config_file.yaml: |-
      databaseUser: {{ .Values.databaseUser }}
      databasePort: 9876
  </code></pre>
  
  <p>which is inconvenient. It works like that because the <code>db_config_file.yaml</code> content is interpreted as string because I give it to the <code>tpl</code> function which only accept strings.</p>
  
  <p>So my question is, is there a way to convert the YAML to string in a Helm template and get the following things:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>databaseUser: "dbuser"
  
  configFiles:
    db_config_file.yaml: # Content is not a string block
      databaseUser: {{ .Values.databaseUser }}
      databasePort: 1234
      [...]
  
  [...]
  </code></pre>
  
  <pre class="lang-yaml prettyprint-override"><code>data:
    {{- range $name, $config := .Values.configFiles }}
    {{ $name }}: |-
  {{ tpl (&lt;a toString function&gt; $config) $ | indent 4 }}
    {{- end }}
  </code></pre>