This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-docs.git
commit 869d5d44be22d30a2d9acb8aaecc249a31a028d7 Merge: bb1e516a 7d8b9a1d Author: Alex Heneveld <[email protected]> AuthorDate: Mon Jul 15 22:36:10 2024 +0100 Merge pull request #378 from nakomis/ternary-operator Adds docs for ternary operator guide/blueprints/workflow/variables.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --cc guide/blueprints/workflow/variables.md index a2b421bb,80dc23d8..1780bfe2 --- a/guide/blueprints/workflow/variables.md +++ b/guide/blueprints/workflow/variables.md @@@ -201,24 -200,18 +201,30 @@@ A limited number of other operations i namely the basic mathematical operands `+`, `-`, `*`, and `/` for integers and doubles, and the modulo operator `%` for integers giving the remainder. These are evaluated in usual mathematical order. + The ternary `?` operator is supported as follows: + + ``` + - let x = <boolean condition> ? <value if true> : <value if false> + ``` + Parentheses are not supported. -The `transform` step can be used for more complicated transformations, such as whether to `wait` on values that are not yet ready, -conversion using `json` and `yaml`, and whether to `trim` strings or yaml documents. -This supports two types of trimming: if a `type` is specified, the value is scanned for `---` on a line by itself -and that token is used as a "document separator", and only the last document is considered; +The `transform` step can be used for more complicated transformations, such as +to `wait` on values that are not yet ready, +to convert `json` and `yaml`, to `trim` strings, merge lists and maps, and much more. +For example: + +``` +- transform x = " [ a, b ] " | trim` # sets x to the string '[ a, b ]' +- transform y = ${x} | json` # sets y to the list of strings '[ "a", "b" ]' +- step: transform | merge | set z` # sets z to the list of strings '[ "a", "b", "c" ]' + value: + - ${x} + - [ c ] +``` + +The `yaml` transform will treat a `---` on a line by itself +as a "document separator", and only the last document is considered; if no `type` is specified, the value has leading and trailing whitespace removed. The former is primarily intended for YAML processing from a script which might include unwanted output prior to the outputting the YAML intended to set in the variable: the script can do `echo ---` before the
