我正在使用一开始具有以下结构的图表,但是我很难理解何时将其评估为true。
{{- if and .Values.vpceIngress.enabled .Values.http.paths (ne .Values.vpceIngress.class "traefik2") }}
我相信enabled
和paths
都必须为真,但是ne
之后会让我失望。
答案 0 :(得分:4)
and
和ne
是go templates中的函数。
and
Returns the boolean AND of its arguments by returning the
first empty argument or the last argument, that is,
"and x y" behaves as "if x then y else x". All the
arguments are evaluated.
ne
Returns the boolean truth of arg1 != arg2
因此模板行相当于更多的伪鳕鱼
if (
.Values.vpceIngress.enabled
&& .Values.http.paths
&& .Values.vpceIngress.class != "traefik2"
)
平原.Value.key
的真实性基本上是“是此字段/关键字not the zero value for the data type”。这也适用于地图,因为地图没有“等价于此字段/关键字已定义”路径设置为nil或非值(请注意,这仅在实际定义父映射时有效!否则,模板错误)