kubekey/docs/zh/101-syntax.md
liujian 9686e047be
fix: change custom function ipInCIDR (#2639)
Signed-off-by: joyceliu <joyceliu@yunify.com>
2025-06-26 03:19:38 +00:00

43 lines
794 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 语法
语法遵循`go template`规范.引用[sprig](https://github.com/Masterminds/sprig)进行函数扩展.
# 自定义函数
## toYaml
将参数转换成yaml字符串. 参数为左移空格数, 值为字符串
```yaml
{{ .yaml_variable | toYaml }}
```
## fromYaml
将yaml字符串转成参数格式
```yaml
{{ .yaml_string | fromYaml }}
```
## ipInCIDR
获取IP范围(cidr)内的所有ip列表(数组)
```yaml
{{ .cidr_variable | ipInCIDR }}
```
## ipFamily
获取IP或IP_CIDR所属的family。返回值为Invalid, IPv4, IPv6
```yaml
{{ .ip | ipFamily }}
```
## pow
幂运算.
```yaml
# 2的3次方, 2 ** 3
{{ 2 | pow 3 }}
```
## subtractList
数组不包含
```yaml
# 返回一个新列表该列表中的元素在a中存在但在b中不存在
{{ .b | subtractList .a }}
```