样书配置
感谢您提供反馈

这篇文章已经过机器翻译.放弃

参数-默认源代码构造

可以使用此构造来重用其他样书中的参数定义。

假设这样一个场景:一个参数或一组参数在多个样书中重复使用。为了避免重新定义这些参数,每次要创建新样书时,可以将其定义一次,然后使用 parameters-default-sources 构造将其定义导入需要这些参数的样书。

例如,如果多个样书需要配置虚拟 IP,可能必须在创建的每个新样书中定义与虚拟 IP 有关的相同参数。相反,您可以创建一个名为的单独样书,例如 vip-params,您可以在其中定义与其相关的所有参数,如以下示例所示:

- 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

然后,您可以使用这些参数创建其他样书

- name: acme-biz-app namespace: com.acme.stylebooks version: "1.0" description: This stylebook defines the NetScaler 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

首先,在样书 acme-biz-app 中,使用“import-stylebooks”部分导入 vip-params 样书的命名空间和版本。然后添加 parameters-default-sources 构造,并指定样书名称,即 vip-params。此参数与直接在此样书中定义 vip-params 样书的参数具有相同的效果。

由于 parameters-default-sources 是一个列表,且列表中的每个项目都需要是一个样书,因此可以包括多个样书中的参数。

除了包括其他样书中的参数外,还可以使用 parameters 部分定义您自己的参数。样书的完整参数列表是从其他样书中添加的参数和此样书中定义的参数的组合。因此,表达式 $parameters 是指此参数组合。

如果在导入的样书和当前样书中都定义了参数,则当前样书中的定义将覆盖从另一个样书导入的定义。如有必要,您可以通过自定义一些导入的参数来有效地使用此方法,同时使用其余导入的参数。

parameters-default-sources 构造还可以用于嵌套的参数中,如下所示:

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

这种方法类似于将样书 vip-params 的参数直接添加为此样书中 vip-details 参数的子参数。

本内容的正式版本为英文版。部分 Cloud Software Group 文档内容采用了机器翻译,仅供您参考。Cloud Software Group 无法控制机器翻译的内容,这些内容可能包含错误、不准确或不合适的语言。对于从英文原文翻译成任何其他语言的内容的准确性、可靠性、适用性或正确性,或者您的 Cloud Software Group 产品或服务沿用了任何机器翻译的内容,我们均不作任何明示或暗示的保证,并且适用的最终用户许可协议或服务条款或者与 Cloud Software Group 签订的任何其他协议(产品或服务与已进行机器翻译的任何文档保持一致)下的任何保证均不适用。对于因使用机器翻译的内容而引起的任何损害或问题,Cloud Software Group 不承担任何责任。
参数-默认源代码构造