go - “if and (ne)”运算符在 helm 中是如何工作的?
问题描述
我正在使用一个开始时具有以下结构的图表,但我很难理解何时评估为真的。
{{- if and .Values.vpceIngress.enabled .Values.http.paths (ne .Values.vpceIngress.class "traefik2") }}
我相信两者都是enabled
真实paths
的,但ne
在那之后让我失望了。
解决方案
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
所以模板行相当于一个更伪的 codish
if (
.Values.vpceIngress.enabled
&& .Values.http.paths
&& .Values.vpceIngress.class != "traefik2"
)
纯文本的真实性.Value.key
基本上是“此字段/键不是数据类型的零值。这也适用于映射,因为“此字段/键是否已定义”,因为映射没有该路径等于 nil 或非值(请注意,这仅在实际定义父地图时才有效!否则模板错误)
推荐阅读
- delphi - StringStream.DataString 访问冲突错误
- java - Vaadin Autocomplete 组件无限循环运行
- python - AWS Lambda 错误:并非所有参数都在字符串格式化期间转换
- swift - 循环在 Swift 中创建 UIImageView 和标签
- open62541 - 使用 open62541 实现 OPC UA 查找别名方法
- mysql - Mysql 触发器创建失败,错误 #1064
- javascript - 为什么我的下拉按钮会抛出这个错误?
- android - 华为机器学习套件下载模型时出现异常
- python - SUMPRODUCT 两列 PYTHON
- .net - 使用代码中的 EF(Core) 迁移重置数据库/表