<p>I'm trying to use a template to pull values from values.yaml, concatenate them into a CSV list. Here's an example of my solution. </p>

<p>values.yaml: </p>

<pre><code>testValue1: "string1"
testValue2: "String2"
credentials: 
- c1: "string3"
- c2: "string4"
</code></pre>

<p>_helpers.tpl:</p>

<pre><code>{{- define "test.template" -}}
{{- $value1 := .Values.testValue1 -}}
{{- $value2 := .Values.testValue2 -}}
{{- $credentials := "" -}}
{{- range $index, $cred := .Values.credentials -}}
{{- $credentials = $cred "," $credentials -}}
{{- end -}}
{{- printf "%s,%s,%s" $value1 $value2 $credentials -}}
{{- end -}}
</code></pre>

<p>test.yaml</p>

<pre><code>templatedValue: {{ template "test.template" }}
</code></pre>

<p>When I run <code>helm template --output-dir outputs chart</code> I get: </p>

<p>test.yaml</p>

<pre><code>templatedValue: %!s(&lt;nil&gt;),%!s(&lt;nil&gt;),
</code></pre>

<p>both the variables I set as values are nil, and the <code>credentials</code> are just an empty string. If I put the values in the values.yaml directly into the <code>test.yaml</code> file it works fine. So I'm not sure why I'm getting these nil values from the template. There's other templates in the <code>_helpers.tpl</code> which grab values from the values.yaml file, so I'm not sure why my template doesn't work. Any help is greatly appreciated.</p>

<pre><code>helm version: 
Client: &amp;version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &amp;version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
</code></pre>

<p>The <code>{{ template &quot;test.template&quot; }}</code> action executes <code>&quot;test.template&quot;</code> template but does not pass any parameters to it. So inside <code>test.template</code> the pipeline will be <code>&lt;nil&gt;</code> and so <code>.Values</code> is invalid.</p>
<p>Quoting from <a href="https://golang.org/pkg/text/template/" rel="nofollow noreferrer"><code>text/template</code></a>:</p>
<blockquote>
<pre><code>{{template &quot;name&quot;}}
  The template with the specified name is executed with nil data.

{{template &quot;name&quot; pipeline}}
  The template with the specified name is executed with dot set
  to the value of the pipeline.
</code></pre>
</blockquote>
<p>You have to pass something in <code>{{template}}</code>. If you have no other info what to pass, try passing the dot <code>.</code>, the current pipeline.</p>
<pre><code>{{ template &quot;test.template&quot; . }}
</code></pre>
