<p>I am creating configmap YAML file using helm, we are injecting JSON data from respective environments folders, but could not get exact helm syntax.</p>
<p>we have a folder structure like files/Dev, files/Tst, Files/ACC, files/PRD</p>
<p>I have environment variable in <strong>values_dev.yaml</strong></p>
<p>environment: Dev</p>
<p>my configmap.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>data: {{- .Files.Get &quot;files/%s/*&quot;.Values.environment&quot; | fromJson | toYaml | nindent 2 }}
</code></pre>
<p>but it did not work.. any help is much-appreciated .thanks in advance</p>

ramesh reddy
<p>If you are planning to <a href="https://kubernetes.io/docs/concepts/storage/volumes/#configmap" rel="nofollow noreferrer">inject Configmap data</a> into a volume</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap
data: 
{{- range $path, $_ :=  .Files.Glob  (printf &quot;files/%s/*&quot; .Values.environment ) }}
  {{ base $path }}: |-
{{ $.Files.Get $path | indent 4 }} 
{{ end }}
</code></pre>
<p>If you want to <a href="http://Configure%20all%20key-value%20pairs%20in%20a%20ConfigMap%20as%20container%20environment%20variables" rel="nofollow noreferrer">configure all key-value pairs in a ConfigMap as container environment variables</a></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap
data: 
{{ $files := (.Files.Glob (printf &quot;files/%s/*&quot; .Values.environment ) ) }}
{{- range $k,$v := $files }}
  {{ $file := fromJson ($.Files.Get $k)  }}
  {{- range $key,$val := $file }}
    {{- $key | squote }}: {{ $val | squote }}
  {{ end }}
{{ end }}
</code></pre>
<p>File structure</p>
<pre><code>.
├── Chart.yaml
├── files
│   └── dev
│       └── file1.json
├── templates
│   ├── _helpers.tpl
│   ├── configmap.yaml
│   └── pod.yaml
└── values.yaml
</code></pre>
