Substitutions 编辑

The substitutions section is used to define shorthand names for complex expressions that can be used in the rest of the StyleBook to make reading the StyleBook easier. They are also useful when the same expression or value is repeated more than once in the StyleBook, for example, a constant value. Using a substitution name for this value allows you to update only the substitution value when this value needs to be changed rather than updating it at every location it appears in the StyleBook, which could be prone to error.

Substitutions are also used for defining mappings between values as described in examples later in this document.

Each substitution in the list is made up of a key and a value.  The value can be a simple value, an expression, a function, or a map.

In the following example, two substitutions are defined. The first one is “http-port” that can be used as a shorthand for 8181. By using a substitution, you can refer to this in the rest of the StyleBook as $substitutions.http-port instead of 8181.

substitutions:

  http-port: 8181

This allows you to specify a mnemonic name to a port number as well as define this port number in one place in the StyleBook, irrespective of the number of times it is used. If you want to modify the port number to 8080, you can modify it in the substitution section, and the change will take effect wherever the mnemonic name http-port is used. The following example shows how a substitution is used in a component.

components:
 -
     name: my-lbvserver-comp
     type: ns::lbvserver
     properties:
          name: $parameters.name + "-lb"
          servicetype: HTTP
          ipv46: $parameters.ip
          port: **$substitutions.http-port**
          lbmethod: $parameters.lb-alg
<!--NeedCopy-->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:3 次

字数:1963

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文