<p>I'm trying to create a config map from a list of values by doing the following</p>

<pre><code>{{- if index .Values "environmentVariables" }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "some-env.fullname" . }}
data:
{{- range $key, $value := .Values.environmentVariables }}
  {{ $key }}: {{ $value }}
{{- end }}
{{- end }}
</code></pre>

<p>With the below values</p>

<pre><code>environmentVariables:
  SERVER_CONTEXT_PATH: /some/where/v2
  SERVER_PORT: 8080
</code></pre>

<p>But that results in the following error message</p>

<pre><code>Error: release my-chart-env-v2-some-env-test failed: ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap: Data: ReadString: expects " or n, parsing 106 ...ER_PORT":8... at {"apiVersion":"v1","data":{"SERVER_CONTEXT_PATH":"/dokument-redskaber/my-chart-app/v2","SERVER_PORT":8080},"kind":"ConfigMap","metadata":{"labels":{"app.kubernetes.io/instance":"my-chart-env-v2-some-env-test","app.kubernetes.io/managed-by":"Tiller","app.kubernetes.io/name":"some-env","helm.sh/chart":"some-env-0.1.0"},"name":"my-chart-env-v2","namespace":"some-env-test"}}
</code></pre>

<p>If I do</p>

<pre><code>  {{ $key }}: {{ $value | quote }}
</code></pre>

<p>it works. But I don't (think I) want to quote all my values. And simply quoting my input value doesn't work. Any suggestions?</p>

user672009
<p>ConfigMap's object <code>data</code> feild requires for all values to be strings. When we have value like <code>8080</code> it reads as int.</p>

<p>What we can do to build <code>ConfigMap</code> object here:</p>

<p><strong>1.</strong> Define all values as strings using <code>quote</code> function:</p>

<p><code>values.yaml</code>:</p>

<pre><code>environmentVariables:
  SERVER_CONTEXT_PATH: /some/where/v2
  SERVER_PORT: 8080
</code></pre>

<p>part of <code>templates/configmap.yaml</code>:</p>

<pre><code>data:
{{- range $key, $value := .Values.environmentVariables }}
  {{ $key }}: {{ $value | quote }}
{{- end }}
</code></pre>

<p><strong>2.</strong> Define all values as strings using double quotes:</p>

<p><code>values.yaml</code>:</p>

<pre><code>environmentVariables:
  SERVER_CONTEXT_PATH: /some/where/v2
  SERVER_PORT: 8080
</code></pre>

<p>part of <code>templates/configmap.yaml</code>:</p>

<pre><code>data:
{{- range $key, $value := .Values.environmentVariables }}
  {{ $key }}: "{{ $value }}"
{{- end }}
</code></pre>

<p><strong>3.</strong> Define all int values as string values in <code>values.yaml</code>:</p>

<p><code>values.yaml</code>:</p>

<pre><code>environmentVariables:
  SERVER_CONTEXT_PATH: /some/where/v2
  SERVER_PORT: '"8080"'
</code></pre>

<p>part of <code>templates/configmap.yaml</code>:</p>

<pre><code>data:
{{- range $key, $value := .Values.environmentVariables }}
  {{ $key }}: {{ $value }}
{{- end }}
</code></pre>

<p>Here is some trick: when value is taken, it's basically taken as <code>"8080"</code>, which can be set exactly as a string value. </p>
