<p><code>helm template sample ./sample-chart --set-file configMaps="{app1.yaml,app2.yaml}"</code></p>

<p>Is the command i am using to set file as values to the chart. And in the chart i am using it set the files as config map.</p>

<p>configmap.yaml:</p>

<pre><code>{{ range $configMap := .Values.configMaps }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ &lt;&lt;file-name&gt; }}-cm
data: 
{{ $configMap | indent 2}}
{{ end }}
</code></pre>

<p>I want to set the config map name, the name of the files whose content is in use as data .i.e app1,app2 in this case. Is there any ways to do this?</p>

Sarabesh n.r
<p>You can ask Helm to <a href="https://helm.sh/docs/chart_template_guide/accessing_files/" rel="nofollow noreferrer">read the file itself</a> when the template is instantiated.  Instead of passing in the contents of the files, pass their names directly.</p>

<p>Adapting <a href="https://helm.sh/docs/chart_template_guide/accessing_files/#basic-example" rel="nofollow noreferrer">the basic example</a> from the Helm documentation, you could write a ConfigMap</p>

<pre><code>{{- $files := .Files }}
{{- range .Values.configMaps }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ . }}-cm
data:
  {{ . }}: |-
    {{ $files.Get . }}
{{- end }}
</code></pre>

<p>(The actual example puts all of the files into a single ConfigMap and that might be a little easier to manage.)</p>

<p>When you run this, you'd give the names of the files and not their contents at the command line (or an auxiliary values file)</p>

<pre><code>helm template sample ./sample-chart --set configMaps="{app1.yaml,app2.yaml}"
</code></pre>
