<p>I am rather new to helm, and I am trying to create a chart, but running into values not transforming from the values.yaml file into my generated chart.</p>
<p>here are my values.yaml</p>
<pre><code>apiVersion: security.istio.io/v1alpha2
kind: RequestAuthentication
metadata:
  name: name01
  namespace: ns-01
spec:
  selector:
    matchLabels:
      app: app-label
  jwtRules:
    - issuer: foo
      jwksUri: bar
      forwardOriginalToken: true
      audiences:
        - user1
        - user2
</code></pre>
<p>then with my helm template:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha2
kind: RequestAuthentication
metadata:
  name: name01
spec:
  selector:
    matchLabels:
      app: {{ .Values.spec.selector.matchLabels.app }}
  jwtRules:
    - issuer: foo
      jwksUri: bar
      forwardOriginalToken: true
      audiences: |-
        {{- range .Values.spec.jwtRules.audiences }}
          - {{ . | title | quote }}
      {{ end }}
---
</code></pre>
<p>I also have a helpers file.</p>
<p>_helpers.tpl</p>
<pre><code>{{/* vim: set filetype=mustache: */}}
{{- define &quot;jwtRules.audiences&quot; -}}
{{- range $.Values.spec.jwtRules.audiences }}
      audiences:
        - {{ . | quote }}
{{- end }}
{{- end }}
</code></pre>
<p>the error its producing: <code>at &lt;.Values.spec.jwtRules.audiences&gt;: can't evaluate field audiences in type interface {}</code></p>

sype
<p>This one is simple - you don't have a <code>spec.jwtRules.audiences</code> in your values file! <code>jwtRules</code> contains an array, so you'll have to <a href="https://stackoverflow.com/questions/64284395/helm-template-get-node-of-first-array-element">use some index</a> or iterate over it. Also, i don't think that neither your indentation, nor using of <code>|-</code> for audiences is correct, per <a href="https://istio.io/latest/docs/reference/config/security/jwt/" rel="nofollow noreferrer">docs</a> it should be an array of strings.</p>
<p>So i came up with this example (your values are unchanged):</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1alpha2
kind: RequestAuthentication
metadata:
  name: name01
spec:
  selector:
    matchLabels:
      app: {{ .Values.spec.selector.matchLabels.app }}
  jwtRules:
    - issuer: foo
      jwksUri: bar
      forwardOriginalToken: true
      audiences:
      {{- with (first .Values.spec.jwtRules) }}
      {{- range .audiences }}
        - {{ . | title | quote -}}
      {{- end }}
      {{- end }}
</code></pre>
<p>renders into:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1alpha2
kind: RequestAuthentication
metadata:
  name: name01
spec:
  selector:
    matchLabels:
      app: app-label
  jwtRules:
    - issuer: foo
      jwksUri: bar
      forwardOriginalToken: true
      audiences:
        - &quot;User1&quot;
        - &quot;User2&quot;
</code></pre>
<p>In this case it uses a first element of array</p>
