我希望能够从如下 Helm 模板文件中插入带有toJson helm 函数的模板,如文档中所述:
value: {{ include "mytpl" . | lower | quote }}
Run Code Online (Sandbox Code Playgroud)
https://helm.sh/docs/howto/charts_tips_and_tricks/#know-your-template-functions
我的配置: _helper.tpl
{{- define "my_tpl" -}}
key1: value1
key2: value2
{{- end -}}
Run Code Online (Sandbox Code Playgroud)
dep.yaml
template:
metadata:
annotations:
test: >-
{{ include "my_tpl" . | toJson }}
Run Code Online (Sandbox Code Playgroud)
这应该返回
template:
metadata:
annotations:
test: >-
{"key1":"value1","key2":"value2"}
Run Code Online (Sandbox Code Playgroud)
但它返回
template:
metadata:
annotations:
test: >-
"key1:value1\nkey2:value2"
Run Code Online (Sandbox Code Playgroud)
我正在使用 Helm v3。有人有什么想法吗?