This content has been machine translated dynamically.
Dieser Inhalt ist eine maschinelle Übersetzung, die dynamisch erstellt wurde. (Haftungsausschluss)
Cet article a été traduit automatiquement de manière dynamique. (Clause de non responsabilité)
Este artículo lo ha traducido una máquina de forma dinámica. (Aviso legal)
此内容已经过机器动态翻译。 放弃
このコンテンツは動的に機械翻訳されています。免責事項
이 콘텐츠는 동적으로 기계 번역되었습니다. 책임 부인
Este texto foi traduzido automaticamente. (Aviso legal)
Questo contenuto è stato tradotto dinamicamente con traduzione automatica.(Esclusione di responsabilità))
This article has been machine translated.
Dieser Artikel wurde maschinell übersetzt. (Haftungsausschluss)
Ce article a été traduit automatiquement. (Clause de non responsabilité)
Este artículo ha sido traducido automáticamente. (Aviso legal)
この記事は機械翻訳されています.免責事項
이 기사는 기계 번역되었습니다.책임 부인
Este artigo foi traduzido automaticamente.(Aviso legal)
这篇文章已经过机器翻译.放弃
Questo articolo è stato tradotto automaticamente.(Esclusione di responsabilità))
Translation failed!
可选属性
在某些情况下,组件的属性从表达式获取其值,该表达式可以是简单的表达式(例如参数引用),也可以是更复杂的表达式。在组件中设置此属性值是可选的。您可以选择仅当表达式返回实际值时才设置属性值,否则可以选择不设置此属性。
例如,假设您要设置的属性之一是类型为 ns::lbvserver 的组件的 lbmethod(负载均衡算法)。lbmethod 属性的值取自用户提供的参数值,如下所示:
components
-
name: lbvserver_comp
type: ns::lbvserver
properties:
name: $parameters.lb-appname + "-lb"
servicetype: $parameters.lb-service-type
ipv46: $parameters.lb-virtual-ip
port: 80
lbmethod: $parameters.lb-advanced.algorithm
<!--NeedCopy-->
现在,假设参数 lb-advanced.algorithm 是一个可选参数。如果用户未提供此可选参数的值,则表达式 $parameters.lb-advanced.algorithm 将评估为空值。因此,lbmethod 属性将传递一个无效值。为避免这种情况,您可以通过在其名称后附加“?”来将该属性标记为可选,如下所示:
components
-
name: lbvserver_comp
type: ns::lbvserver
properties:
name: $parameters.lb-appname + "-lb"
servicetype: $parameters.lb-service-type
ipv46: $parameters.lb-virtual-ip
port: 80
lbmethod?: $parameters.lb-advanced.algorithm
<!--NeedCopy-->
使用“?”会在右侧表达式评估为空时省略该属性,在本例中,这等同于按如下方式定义的组件:
components
-
name: lbvserver_comp
type: ns::lbvserver
properties:
name: $parameters.lb-appname + "-lb"
servicetype: $parameters.lb-service-type
ipv46: $parameters.lb-virtual-ip
port: 80
<!--NeedCopy-->
由于 lbmethod 是可选的,省略它仍然会使此组件有效。请注意,如果 lbmethod 的类型“ns::lbvserver”中定义了默认值,则 lbmethod 可能会采用其默认值。
共享
共享
This Preview product documentation is Cloud Software Group Confidential.
You agree to hold this documentation confidential pursuant to the terms of your Cloud Software Group Beta/Tech Preview Agreement.
The development, release and timing of any features or functionality described in the Preview documentation remains at our sole discretion and are subject to change without notice or consultation.
The documentation is for informational purposes only and is not a commitment, promise or legal obligation to deliver any material, code or functionality and should not be relied upon in making Cloud Software Group product purchase decisions.
If you do not agree, select I DO NOT AGREE to exit.