<p>I want to choose config section from values.yaml by setting a variable in helm command line.</p>

<p>example part of values.yaml:</p>

<pre><code>aaa:
  x1: "az1"
  x2: "az2"
bbb:
  x1: "bz1" 
  x2: "bz2"
</code></pre>

<p>example part of configmap.yaml</p>

<pre><code>data: 
  {{ .Values.outsideVal.x1 }}
</code></pre>

<p>Expected result should looks like this</p>

<pre><code>   data:
     az1
</code></pre>

<p>Test helm output</p>

<pre><code>helm template --set outsideVal=aaa mychart
</code></pre>

<p>And got this error</p>

<pre><code>Error: render error in "./templates/configmap.yaml": template: ./templates/configmap.yaml:21:12: executing "./templates/configmap.yaml" at &lt;.Values.outsideVal.x...&gt;: can't evaluate field x1 in type interface {}
</code></pre>

<p>So the question is how get the result as expected?</p>

<p>I suspect you're looking for the <a href="https://godoc.org/text/template" rel="noreferrer">text/template</a> <code>index</code> function, which can look up a value in a map by a variable key.</p>

<pre><code>{{ (index .Values .Values.outsideVal).x1 }}
</code></pre>
