<p>I'm trying to reference a value from my Values.yaml file in Helm in a Files.Glob method.</p>
<p>Here is my Configmap template:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: cm
data:
  {{- tpl ((.Files.Glob &quot;qa.ns1/*&quot;).AsConfig) . | nindent 2 }}
</code></pre>
<p>The above works as expected.</p>
<p>The folder structure is &quot;environment.namespace&quot;. ns1 is the name of my namespace. How do I reference a value from my Values.yaml file instead of ns1?</p>
<p>I have tried:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: cm
data:
  {{- tpl ((.Files.Glob &quot;qa.{{ .Values.namespace }}/*&quot;).AsConfig) . | nindent 2 }}
</code></pre>
<p>Where my Values.yaml file is:</p>
<pre><code>namespace: ns1
</code></pre>
<p>I get no data in my configmap when I reference it with above. Any help would be appreciated!</p>

firebolt
<p>I'd use the <a href="https://godoc.org/text/template" rel="nofollow noreferrer">Go text/template</a> <code>printf</code> function.  Split out into variables this would look like:</p>
<pre><code>data:
  {{- $glob := printf &quot;qa.%s/*&quot; .Values.Namespace }}
  {{- $data := (.Files.Glob $glob).AsConfig }}
  {{- tpl $data . | nindent 2 }}
</code></pre>
<p>The <a href="http://masterminds.github.io/sprig/strings.html" rel="nofollow noreferrer">Sprig <code>cat</code> function</a> would also work</p>
<pre><code>{{- $glob := cat &quot;qa.&quot; .Values.Namespace &quot;/*&quot; }}
</code></pre>
<p>Once you're inside the <code>{{ ... }}</code> template block, you can't nest template blocks, but you can just directly refer to variables and Helm values.</p>
