<p>I have a values file like:</p>
<pre><code>secrets:
  file.tst |
    {
      content ....
    }
</code></pre>
<p>And I would like to get file.tst name in the yaml template. I already tried with:</p>
<pre><code>{{ .Values.secrets.secrets |trimSuffix &quot;-&quot; }}
</code></pre>
<p>But it doesn't work.</p>

Michael
<p>With that <code>values.yaml</code> layout, <code>.Values.secrets</code> is itself a dictionary, with string keys and string values.  Helm includes <a href="https://docs.helm.sh/docs/chart_template_guide/function_list/" rel="nofollow noreferrer">many functions</a> that can operate on details of these.  In particular, you can call <a href="https://docs.helm.sh/docs/chart_template_guide/function_list/#keys" rel="nofollow noreferrer"><code>keys</code></a> to get the keys of a dictionary as a list, and <a href="https://docs.helm.sh/docs/chart_template_guide/function_list/#first-mustfirst" rel="nofollow noreferrer"><code>first</code></a> to get the first item out of a list.</p>
<pre class="lang-yaml prettyprint-override"><code>firstFilename: &quot;{{ .Values.secrets | keys | first }}&quot;
</code></pre>
<p>You can also use the built-in <code>range</code> function to iterate over either the map itself or the list of keys.</p>
<pre class="lang-yaml prettyprint-override"><code>hashes:
{{- $filename, $contents := range .Values.secrets }}
  {{ $filename }}: &quot;{{ sha256sum $contents }}&quot;
{{- end }}
</code></pre>
