我正在尝试在 helm range 中使用 include 语句,但是
I am getting an error can't evaluate field Values in type string.
测试.yaml
spec:
rules:
{{- range .Values.tests }}
- host: {{ . }}
http:
paths:
- backend:
service:
name: test-{{ $.Values.somename }}
port:
number: {{- include "testit.get_port" }}
path: /
pathType: ImplementationSpecific
{{- end }}
而_helper.tpl就是这个
{{- define "testit.get_port" }}
{{- if (eq .Values.somtest "test1") }}5000{{- else }}80{{- end }}
{{- end }}
我知道使用值时,如果在范围循环中使用,则必须使用 $ 符号。包含怎么样,我应该在那里使用什么
您没有在
include
调用中包含任何参数,因此模板将 nil
作为其参数。在 range
循环内,您可能需要传递 $
顶级对象
number: {{- include "testit.get_port" $ }}
# ^