2.6.3.2.8. toInt function
toInt 函数处理并返回输入值的整数值。另外,如果这是模板中的最后一个功能,也会进一步处理源内容。这是为了确保该值由 YAML 解释为整数。查看该功能的以下语法:
func toInt (input interface{}) (output int)
使用函数时,输入需要转换为整数的数据。查看以下使用 toInt 功能的配置策略示例:
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: demo-template-function
namespace: test
spec:
namespaceSelector:
exclude:
- kube-*
include:
- default
object-templates:
- complianceType: musthave
objectDefinition:
...
spec:
vlanid: |
{{ (fromConfigMap "site-config" "site1" "vlan") | toInt }}