<p>I have got several namespaces (iso, dev, sandbox, etc.) which correspond to my different environments. For each environment and thus namespace, there is an associated db.
When I deploy my pod with Helm, I would like to inject the namespace inside a value to get the appropriate password . </p>

<p>In my values file I have something that looks like this :</p>

<pre><code>db:
  iso: passwordISO
  dev: passwordDEV
  sandbox: passwordSANDBOX
  spec: passwordSPEC
  val: passwordVAL
</code></pre>

<p>and in my consumer_config file I have this :</p>

<pre><code>  db_host: DB_HOST-{{ .Release.Namespace }}
  db_port: DB_PORT
  db_name: DB_NAME
  db_user: DB_PORT
  db_password: {{ .Values.db.iso }}
</code></pre>

<p>I already tried to use the <code>{{- include }}</code> pattern but with no success. I also tried <code>{{ .Values.db.{{ .Release.Namespace }}}}</code> giving me the following error <code>unexpected &lt;.&gt; in operand</code></p>

<p>Any insight on how to do this or any workaround ?</p>

<p>As Helm is based on the Go-template language, the functions availabe in the go-template language can be of help:</p>

<pre><code>{{ index .Values.db .Release.Namespace }}
</code></pre>

<p>From the docs (go-template docs):</p>

<blockquote>
  <p>index
      Returns the result of indexing its first argument by the
      following arguments. Thus "index x 1 2 3" is, in Go syntax,
      x[1][2][3]. Each indexed item must be a map, slice, or array.</p>
</blockquote>

<p>so in this case you index <code>.Values.db</code> with the key <code>.Release.Namespace</code></p>
