the configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "test.fullname" . }}-config-map
data:
brokerConf: |
{{ .Values.configmap }}
the below values.yaml is right.
configmap: |
key=values
but the values.yaml is wrong
configmap: |
key=values
key2=values2
the helm template core content is
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-map
data:
brokerConf: |
key=values
key2=values2
the error
Error: YAML parse error on test/templates/config-map.yaml: error converting YAML to JSON: yaml: line 9: could not find expected ':'
helm.go:84: [debug] error converting YAML to JSON: yaml: line 9: could not find expected ':'
YAML parse error on v5-proxy/templates/config-map.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
helm.sh/helm/v3/pkg/action/action.go:165
how to fix it?
CodePudding user response:
You may update the configmap
as below:
apiVersion: v1
kind: ConfigMap
metadata:
name: config-map
data:
brokerConf:
{{ .Values.configmap| indent 4|trim }}
The error is caused because the 2nd line in data.brokerConf
is not indented properly. Something like below, where key=val
is an invalid statement in yaml world, the correct is key: val
.
configmap:
key=values
key2=values2
To fix it we have to use indent
, but it will do indent the first line additionally. To address that, trim
is used.