<p>I have defined application.properties files in a config dir. Config dir is on the below structure.</p>

<pre><code>config
  application.properties
  application-test.properties
  application-dev.properties
  application-prod.properties
</code></pre>

<p>I have created a helm chart to create the configmap. Helm chart is defined as below</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-configmap
data:
  {{- (.Files.Glob "config/*").AsConfig | nindent 2 }}
</code></pre>

<p>I see that the configmap is created. </p>

<p>We are consuming the ConfigMap via environment variables in a running container using the <code>envFrom</code> property. (This in my deployment yaml file)</p>

<pre><code>spec:
   containers:
   - envFrom:
     - configMapRef:
         name: nginx-configmap
</code></pre>

<p>I see that the values are stored as environment variables. However the variables are in lower cases. </p>

<pre><code>server.port=8080
server.name=localhost
</code></pre>

<p>Since these are env variables, they have to be uppercase and . should be replaced with _. So, I have modifed my chart as below</p>

<pre><code>data:
  {{- (.Files.Glob "config/*").AsConfig | nindent 2 | upper | replace "." "_" }}

</code></pre>

<p>The generated configmap is as below</p>

<pre><code>  APPLICATION_PROPERTIES: |
    SERVER_PORT = 8080
    SERVER_NAME = LOCALHOST
</code></pre>

<p>Below is the env variables inside container</p>

<pre><code>APPLICATION_PROPERTIES=SERVER_PORT = 8080
SERVER_NAME = LOCALHOST
</code></pre>

<p>My requirement is that only the contents of the file should be upper case and . should be replaced with _.  The filename should not be converted. The filename should be as is.</p>

<p>Can this be achieved? </p>

<p>Try this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-configmap
data:
  {{ $root := . }}
  {{ range $path, $bytes := .Files.Glob "config/*" }}
  {{ base $path }}: '{{ $root.Files.Get $path | nindent 2 | upper | replace "." "_"  }}'
  {{ end }}
</code></pre>
