<p>I am setting the following environment variable in Helm Deployment like so.</p>
<pre><code>name: SERVER_ENDPOINT
value: {{ .Values.server.dev_proxy_endpoint }}
</code></pre>
<p>But would like to interpolate the environment part (dev) of the value variable, like so</p>
<pre><code>name: SERVER_ENDPOINT
value: {{ .Values.server. {{ .Values.environment | lower }} _proxy_endpoint }}
</code></pre>
<p>Is this possible?</p>
<h1>Reply to first comment</h1>
<p>I tried that out by creating a new definition at the top of the file like so:</p>
<pre><code>{{- $value_path_to_endpoint := print &quot;.Values.server.&quot; .Values.environment  &quot;_proxy_endpoint&quot; -}}
</code></pre>
<p>But that then presents a literal value, rather than the context pointer to the values file.</p>
<pre><code>name: SERVER_ENDPOINT
value: {{ $value_path_to_endpoint}}
</code></pre>
<p>In other words, $value_path_to_endpoint returns:</p>
<pre><code>&quot;.Values.server.dev_proxy_endpoint&quot;
</code></pre>
<p>Rather than</p>
<pre><code>.Values.server.dev_proxy_endpoint
</code></pre>

<p>You can use <code>index</code> function from <a href="https://golang.org/pkg/text/template/" rel="nofollow noreferrer">Go text/template</a> and Helm's <a href="https://helm.sh/docs/chart_template_guide/function_list/#printf" rel="nofollow noreferrer">printf function</a></p>
<pre><code>env:
- name: SERVER_ENDPOINT
  value: {{ (index .Values.server (printf &quot;%s_proxy_endpoint&quot; ( .Values.environment | lower ))) }}
</code></pre>
