<p>I have the following <code>define</code> definition in helm:</p>
<pre><code>{{- define &quot;svc.envVars&quot; -}}
{{- range .Values.envVars.withSecret }}
- name: {{ .key }}
  valueFrom:
    secretKeyRef:
      name: {{ .secretName }}
      key: {{ .secretKey | quote }}
{{- end }}
{{- range .Values.envVars.withoutSecret }}
- name: {{ .name }}
  value: {{ .value | quote }}
{{- end }}
{{- end }}
</code></pre>
<p>and I am going to use it in <code>deployment.yaml</code></p>
<pre><code>  containers:
    - name: {{ .Release.Name }}
      image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot;
      imagePullPolicy: {{ .Values.image.pullPolicy }}
      {{- if .Values.envVars.enabled }}
      env:
      {{- include &quot;svc.envVars&quot; . | indent 10 }} 
      {{- end }}
      ports:
        - name: http
          containerPort: 8080
          protocol: TCP
      livenessProbe:
        httpGet:
          path: /
          port: http
      readinessProbe:
        httpGet:
          path: /
          port: http
      resources:
        {{- toYaml .Values.resources | nindent 12 }}
</code></pre>
<p>in <code>values.yaml</code> it is defined as follows:</p>
<pre><code>envVars:
  enabled: false
  withSecret: []
  withoutSecret: []
</code></pre>
<p>then I tried to render:</p>
<pre><code>helm template --debug user-svc \
  --set image.tag=0.1.0 \
  --set image.repository=user-svc \
  --set envVars.enabled=true \
  --set envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw \
  --set envVars.withSecret[1].key=MYSQL_URL,envVars.withSecret[1].secretName=mysql_name,envVars.withSecret[1].secretKey=mysql_pw \
  ./svc
</code></pre>
<p>it shows me:</p>
<pre><code>zsh: no matches found: envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw
</code></pre>
<p>When I set the variables manually in <code>values.yaml</code>:</p>
<pre><code>envVars:
  enabled: false
  withSecret:
    - key: POSTGRES_URL
      secretName: postgres_name
      secretKey: postgres_pw
    - key: MYSQL_URL
      secretName: mysql_name
      secretKey: mysql_pw  
  withoutSecret:
    - name: NOT_SECRET
      value: &quot;Value of not serect&quot;
</code></pre>
<p>then render it with:</p>
<pre><code>helm template --debug user-svc \
  --set image.tag=0.1.0 \
  --set image.repository=user-svc \
  --set envVars.enabled=true \
  ./svc
</code></pre>
<p>then it works as expected.</p>
<p>What am I doing wrong?</p>

softshipper
<p>I had the same issue. Due to the fact, that ´[´ and ´]´ are interpreted by zsh.
You can use <code>noglob</code> to disable the globals. So, ´[´ and ´]´ are not interpreted.</p>
<pre class="lang-sh prettyprint-override"><code>noglob helm template --set lorem[0].ipsum=1337
</code></pre>
<p>In your example:</p>
<pre class="lang-sh prettyprint-override"><code>noglob helm template --debug user-svc \
  --set image.tag=0.1.0 \
  --set image.repository=user-svc \
  --set envVars.enabled=true \
  --set envVars.withSecret[0].key=POSTGRES_URL,envVars.withSecret[0].secretName=postgres_name,envVars.withSecret[0].secretKey=postgres_pw \
  --set envVars.withSecret[1].key=MYSQL_URL,envVars.withSecret[1].secretName=mysql_name,envVars.withSecret[1].secretKey=mysql_pw \
  ./svc
</code></pre>
<p>Sources:</p>
<ul>
<li><a href="https://imlc.me/helm-zsh-no-matches-found-imagepullsecrets-0-.name-regcred" rel="noreferrer">Helm - zsh: no matches found: imagePullSecrets[0].name=regcred</a>¨</li>
</ul>
