<p>consider this values.yaml file and secrets.yaml fle.
Is there  any way to read <code>prometheus.promethesSpec.thanos.objectStorageConfig.name</code> and<br>
pass the data of the variable <code>thanosObjectStoreConfig</code> (which is the value of above dict) to the secrets.yaml ?</p>

<p><strong>values.yaml</strong></p>

<pre><code>prometheus:
  prometheusSpec:
    thanos:
      image: thanosio/thanos:v0.11.0
      objectStorageConfig:
        name: thanosObjectStoreConfig
        key: storage

# Defining storage configs for thanos
thanosObjectStoreConfig:
  type: AZURE
  config:
    storage_account: "xxxxxxx"
    storage_account_key: "xxxxxxxxx"
    container: "prometheus"
    endpoint: "blob.core.windows.net"
    max_retries: 0
</code></pre>

<p><strong>secrets.yaml</strong></p>

<pre><code>{{- if .Values.prometheus.prometheusSpec.thanos }}
---
apiVersion: v1
kind: Secret
metadata:
  name: thanos-object-store-config
type: Opaque
data:
  storage: &lt; should contain values of `thanosObjectStorageConfig` | b64enc &gt;
  # Tried not working as expected
  # storage: {{ tpl .Values.prometheus.prometheusSpec.thanos.objectStorageConfig.name $ }}
{{ end }}
</code></pre>

Rajesh Rajendran
<p>The easiest approach is to avoid the problem entirely.  When you <code>helm install</code> or <code>helm upgrade</code> a chart, you can provide any number of <code>-f</code> options to specify additional YAML values files.  You can put the specific storage configuration (what you have under the <code>thanosObjectStoreConfig</code> top-level key) in a separate file, with a fixed top-level key, and <code>helm install -f</code> with different files in different environments.</p>

<pre><code>helm install -f values-production.yaml ...
</code></pre>

<p>If you really want to switch this based on a key, the core Go <a href="https://godoc.org/text/template" rel="nofollow noreferrer">text/template</a> language includes an <code>index</code> function that can do a dynamic lookup:</p>

<pre><code>{{- $key := .Values.prometheus.prometheusSpec.thanos.objectStorageConfig.name }}
data:
  storage: {{ index .Values $key | toYaml | b64enc }}
</code></pre>
