在这篇 Stack Overflow 帖子中,您似乎应该能够渲染文本,toYaml
然后将其传递给,tpl
但这对我不起作用。
采取以下措施:
#values.yaml
configMaps:
test:
data:
config.yaml: |-
aaaaaa: sdlkfjlskdfj
bbbb: sdlkfjlskdfj
ccccc: sdlkfjlskdfj
ssdfs: slkdjflksdj
cccc: sdlkfjlskdfj
lskdjflksd: slkdjflksdj
sdfs: slkdjflksdj
AList:
- aaaa
- bbbb
- cccc
#In my chart
apiVersion: v1
kind: ConfigMap
metadata:
name: mymap
data:
{{ tpl (toYaml .Values.configMaps.test.data) . }}
这一直有效,直到我实际向需要渲染的文本添加一些内容。
当我尝试向该文本添加函数时,出现错误:
#values.yaml
configMaps:
test:
data:
config.yaml: |-
valueFromFunction: prefix-{{ include "myfunction" . }}-suffix
aaaaaa: sdlkfjlskdfj
bbbb: sdlkfjlskdfj
ccccc: sdlkfjlskdfj
ssdfs: slkdjflksdj
cccc: sdlkfjlskdfj
lskdjflksd: slkdjflksdj
sdfs: slkdjflksdj
AList:
- aaaa
- bbbb
- cccc
那是因为当它到达tpl
函数时看起来像这样:include \\\"myfunction\\\"\n
tpl
我尝试先运行它,但这给了我另一个错误:wrong type for value; expected string; got map[string]interface {}