重复条件构造
重复条件构造在重复构造的每次迭代中进行评估,其结果决定是在该迭代中构建配置对象还是进入下一次迭代。以下示例展示了重复条件构造的用法:
示例:
components
-
name: der-key-files-comp
type: ns::systemfile
repeat:
repeat-list: $parameters.certificates
repeat-item: certificate
repeat-condition: $certificate.ssl-inform == DER
properties:
filecontent: base64($certificate.keyfile.contents)
fileencoding: BASE64
filelocation: /nsconfig/ssl
filename: $certificate.keyfile.file
在此示例中,der-key-files-comp 组件遍历用户提供的所有证书,但它只构建与采用 DER 编码的证书对应的配置对象。在每次迭代中,重复条件表达式都会被评估,以测试证书编码是否为 DER 类型。如果不是 DER 类型,则在当前迭代中不构建任何配置对象,并且迭代将移至列表中的下一个证书。