I want to pass a list object in the data section of configMap in application YAML file.
I have the following list in the properties file:
abc.management.provider[0].url=https://example.com
abc.management.provider[0].username=John
abc.management.provider[1].url=https://example2.com
abc.management.provider[1].username=Targerian
YAML file:
data:
abc_management:
provider:
- url: "https://example.com"
username: "John"
- url: "https://example2.com"
username: "Targerian"
I'm getting this error: ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap: Data: ReadString: expects " or n,.
what should I do?
I think this question points to what the nature of a ConfigMap object is. Under the hood, it seems ConfigMap
s do not explicitly handle lists, so in the end it just depends on how you read that content.
The data field is designed to contain UTF-8 byte sequences ...
Each key under the data or the binaryData field must consist of alphanumeric characters, -, _ or .. The keys stored in data must not overlap with the keys in the binaryData field.
https://kubernetes.io/docs/concepts/configuration/configmap/#configmap-object
what should I do?
This mostly depends on how your application reads the configuration.
If it works for you, you an create the ConfigMap
directly with your properties-file:
kubectl create configmap app-config --from-file=app.properties