I have a "YAML" file. And I want to validate it before I render the go-template variables in it. For example:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
myvalue: "Hello World"
drink: {{ .Values.favorite.drink | default "tea" | quote }}
food: {{ .Values.favorite.food | upper | quote }}
The typical YAML parser doesn't work here, as it will parse { as the start of a map.
err := yaml.Unmarshal(data, &Content)
// Failed to parse the provided YAML: yaml: line 4: did not find expected key
I wonder if there is any package that can help me do this? I've searched online for a while but have no luck. Thanks for any help!