<p>I have an helm chart used to deploy a spring service that have configuration file in YAML file. Currently, my helm chart use the following code:</p>
<p><strong>templates/configmap.yaml</strong></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: account-service-config
data:
  variable.yml:
    {{ range $key, $value := .Values.spring.config.content | indent 4  }}
                            {{ $key | indent 2}}={{ $value }}
                                {{printf &quot;\n&quot; }}
                            {{- end -}}
</code></pre>
<p>I have a <em><strong>values.yaml</strong></em> as below</p>
<pre><code>spring:
  config:
    content: |-
      spring:
        application:
          name: hello
        security:
              abc:
                abc-def: ${url}
</code></pre>
<p>The problem is that if I want to change the value of anything for e.g application name, I have to rewrite the entire configuration like that:</p>
<pre><code>spring:
  config:
    content: |-
      spring:
        application:
          name: valuechange
        security:
              abc:
                abc-def: ${url}
</code></pre>
<p>So my question is, is there a way to convert the string to Yaml in a Helm template. I wanted it to be converted into helm yaml and inject it through configmaps in deployment file.</p>
<p>The helm templates are common for many services so I cannot explicitly define the values as they are different for each service and I am overriding the values.yaml by another file called values.yaml in respective spring service repository.</p>

Saifina Maredia
<p>You can use the function called <code>toYaml</code> like this:</p>
<pre><code>  variable.yml: |-
{{ toYaml .Values.spring.config.content | indent 4 }}
</code></pre>
<p>We use something similar in our Hazelcast Helm Chart. Please check the details <a href="https://github.com/hazelcast/charts/blob/master/stable/hazelcast/templates/config.yaml#L17" rel="nofollow noreferrer">here</a>.</p>
