<p>I am trying to create ConfigMap in OpenShift by using YAML file.</p>
<p>My YAML is having a list of values as below.</p>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: sample-map-json-fields
  namespace: default
data:
  fields:
    - hello
    - world
    - my.test.field
</code></pre>
<p>I executed like below -</p>
<pre><code> oc create -f filename.yaml
</code></pre>
<p>Getting exception like below -</p>
<blockquote>
<p>Error from server (BadRequest): error when creating &quot;filename.yaml&quot;:
ConfigMap in version &quot;v1&quot; cannot be handled as a ConfigMap: [pos 42]:
json: expect char '&quot;' but got char '['</p>
</blockquote>
<p>If I do the same without list content inside data, it works.</p>
<p>Please help how to handle the YAML list for ConfigMap.</p>

Jet
<p>This is not working because you are providing <code>array</code> whereas Kubernetes expects to receive <code>string</code> .</p>
<pre><code>got &quot;array&quot;, expected &quot;string&quot;
</code></pre>
<p>Please read more about <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#configmap-v1-core" rel="nofollow noreferrer">configMap</a> in Kubernetes API documentation:</p>
<pre><code>data  - _object_   

Data contains the configuration data. Each key must
consist of alphanumeric characters, '-', '_' or '.'. Values with
non-UTF-8 byte sequences must use the BinaryData field. The keys
stored in Data must not overlap with the keys in the BinaryData field,
this is enforced during validation process.
</code></pre>
<p>Or in the go <a href="https://godoc.org/k8s.io/api/core/v1#ConfigMap" rel="nofollow noreferrer">docs</a>:</p>
<pre><code>// Data contains the configuration data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// Values with non-UTF-8 byte sequences must use the BinaryData field.
// The keys stored in Data must not overlap with the keys in
// the BinaryData field, this is enforced during validation process.
// +optional


Data map[string]string `json:&quot;data,omitempty&quot; protobuf:&quot;bytes,2,rep,name=data&quot;`
</code></pre>
