Parameters-default-sources construct 编辑

You can use this construct to reuse parameter definitions from other StyleBooks.

Consider a scenario where a parameter or a group of parameters is used repeatedly in multiple StyleBooks. To avoid redefining these parameters, each time you want to create a new StyleBook, you can define them once, and then import their definitions into the StyleBooks that need these parameters by using the parameters-default-sources construct.

For example, if many of your StyleBooks need to configure a virtual IP, you might have to define the same parameters related to virtual IPs in each new StyleBook you create. Instead, you can create a separate StyleBook called, for example, “vip-params” where you define all the parameters related to it as shown in the following example:

     -
     name: vip-params
     namespace: com.acme.commontypes
     version: "1.0"
     description: This StyleBook defines a typical virtual IP config.
     private: true
     schema-version: "1.0"
     parameters:
       -
           name: lb-appname
           label: Load Balanced Application Name
          description: Name of the Load Balanced application
           type: string
           required: true
       -
           name: lb-virtual-ip
           label: Load Balanced App Virtual IP address
           description: Virtual IP address representing the Load Balanced application
           type: ipaddress
           required: true
       -
           name: lb-virtual-port
           label: Load Balanced App Virtual Port
           description: TCP port representing the Load Balanced application
           type: tcp-port
           default: 80
       -
           name: lb-service-type
           label: Load Balanced App Protocol
           description: Protocol used for the Load Balanced application.
           type: string
           default: HTTP
           required: true
           allowed-values:
                - HTTP
                - SSL
                - TCP
<!--NeedCopy-->

Then, you can create other StyleBooks that make use of these parameters. Following is an example of such a StyleBook.

     -
     name: acme-biz-app
     namespace: com.acme.stylebooks
     version: "1.0"
     description: This stylebook defines the Citrix ADC configuration for Biz App
     schema-version: "1.0"
     import-stylebooks:
       -
          namespace: com.acme.commontypes
          prefix: cmtypes
          version: "1.0"
     parameters-default-sources:
           - cmtypes::vip-params
     parameters:
         -
           name: monitorname
           label: Monitor Name
           description: Name of the monitor
           type: string
           required: true
         -
           name: type
           label: Monitor Type
           description: Type of the monitor
           type: string
           required: true
           allowed-values:
             - PING
             - TCP
             - HTTP
             - HTTP-ECV
             - TCP-ECV
             - HTTP-INLINE
<!--NeedCopy-->

In the StyleBook, acme-biz-app, first, the namespace and version of the vip-params StyleBook is imported by using the “import-stylebooks” section. Then the parameters-default-sources construct is added, and the StyleBook name, that is, vip-params is specified. This has the same effect as defining the parameters of the vip-params StyleBook directly in this StyleBook.

You can include parameters from multiple StyleBooks because the parameters-default-sources is a list, and each item in the list is expected to be a StyleBook.

In addition to including parameters from other StyleBooks, you can also define your own parameters by using the parameters section. The complete list of parameters of the StyleBook is the combination of parameters included from other StyleBooks and parameters defined in this StyleBook. Therefore, the expression $parameters refers to this combination of parameters.

Note that if a parameter is defined both in an imported StyleBook as well as in the current StyleBook, the definition in the current StyleBook overrides the definition imported from another StyleBook. You can use this effectively by customizing a few of the imported parameters if required, while using the rest of the imported parameters as they are.

The parameters-default-sources construct can also be used in nested parameters as shown:

parameters:
    -
      name: vip-details
      label: Virtual IP details
      description: Details of the Virtual IP
      type: object
      required: true
      parameters-default-sources:
              - cmtypes::vip-params
<!--NeedCopy-->

This is similar to having the parameters of the StyleBook vip-params added directly as child parameters of the vip-details parameter in this StyleBook.

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

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

发布评论

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

词条统计

浏览:9 次

字数:5592

最后编辑:7 年前

编辑次数:0 次

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