<p>I have a basic kubernetes helm template like below</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
data:
  config.tpl: |
{{- default ((tpl .Values.configTpl .) | indent 4)  (tpl (.Files.Get &quot;files/config.tpl&quot;) . | indent 4) -}}
</code></pre>
<p>and the values.yml file</p>
<pre><code>configTpl: |
   {{ x=8gwifi.org }}
</code></pre>
<p>When i apply the helm chart it throw me an error</p>
<pre><code>❯ helm upgrade  mychart . --namespace=test --create-namespace --debug
upgrade.go:142: [debug] preparing upgrade for mychart
Error: UPGRADE FAILED: YAML parse error on 8gwifi.org-test/templates/configmap-logfilegen.yaml: error converting YAML to JSON: yaml: line 11: did not find expected comment or line break
helm.go:84: [debug] error converting YAML to JSON: yaml: line 11: did not find expected comment or line break
</code></pre>
<p>I tried different configuration</p>
<pre><code>config.tpl: |
    {{- default (tpl .Values.configTpl . | indent 4) (tpl (.Files.Get &quot;files/config.tpl&quot;) . | indent 4) -}}
</code></pre>
<p>still resulting in same error, Is there a way to specify a config value if none is passed then used the hardcoded one</p>
<p>I'm sure it's an YAML syntx issue couldn't figure it out checked all cases</p>
<p><strong>Based on David suggestion</strong></p>
<p>Template debug is showing this</p>
<pre><code>data:
  config.tpl: |-
       x := 8gwifi.org
   y := &quot;functions&quot;
</code></pre>
<p><strong>I can cleary see y is not indent and throwing YAML syntax error, not sure how to fix this</strong></p>
<p>This is the updated definition</p>
<pre><code>data:
  config.tpl: |-
    {{ (tpl .Values.configTpl . | indent 4)  | default (tpl (.Files.Get &quot;files/config.tpl&quot;) . | indent 4) -}}
</code></pre>
<p>values.yml</p>
<pre><code>configTpl: |
   x := &quot;8gwifi.org&quot;
   y := &quot;function&quot;
</code></pre>

anish
<p>You're hitting problems with whitespace in the first line of the block scalar.  You should check two things:</p>
<ol>
<li>The template block containing <code>indent</code> must not itself be indented, it must start at the first column of its line; and</li>
<li>The template block containing <code>indent</code> must not have a <code>-</code> inside the opening curly braces.</li>
</ol>
<pre class="lang-yaml prettyprint-override"><code>{{- $configTpl := .Values.configTpl | default (.Files.Get &quot;tiles/config.tpl&quot;) }}
  config.tpl: |
{{ tpl $configTpl . | indent 4 }}
</code></pre>
<p>The templating language isn't really aware of YAML syntax as it runs.  If you have spaces in front of the <code>indent</code> line, they will get emitted, and then <code>indent</code> adds its own leading space, resulting in the last output you get where the first line is indented extra.  The <code>-</code> whitespace control marker will also consume the preceding newline, resulting in the first line of the output being on the same line as the YAML block scalar marker.</p>
