Fix incorrect flow example and improve operator documentation

Signed-off-by: Alex <login@sneaksneak.org>
pull/4919/head
Alex 7 years ago committed by Alex Speaks
parent 5a404f114e
commit 648876899d

@ -53,7 +53,7 @@ data:
myvalue: "Hello World"
drink: {{ .Values.favorite.drink | default "tea" | quote }}
food: {{ .Values.favorite.food | upper | quote }}
{{ if and (.Values.favorite.drink) (eq .Values.favorite.drink "coffee") }}mug: true{{ end }}
{{ if and .Values.favorite.drink (eq .Values.favorite.drink "coffee") }}mug: true{{ end }}
```
Note that `.Values.favorite.drink` must be defined or else it will throw an error when comparing it to "coffee". Since we commented out `drink: coffee` in our last example, the output should not include a `mug: true` flag. But if we add that line back into our `values.yaml` file, the output should look like this:

@ -150,6 +150,16 @@ Template functions and pipelines are a powerful way to transform information and
## Operators are functions
For templates, the operators (`eq`, `ne`, `lt`, `gt`, `and`, `or` and so on) are all implemented as functions. In pipelines, operations can be grouped with parentheses (`(`, and `)`).
Operators are implemented as functions that return a boolean value. To use `eq`, `ne`, `lt`, `gt`, `and`, `or`, `not` etcetera place the operator at the front of the statement followed by its parameters just as you would a function. To chain multiple operations together, separate individual functions by surrounding them with paranthesis.
```yaml
{{ if and .Values.fooString (eq .Values.fooString "foo") }}
#Include this when the variable .Values.fooString exists and is set to "foo"
{{ end }}
{{ if or .Values.unsetVariable (not .Values.setVariable) }}
#do not include this because unset variables evaluate to false and .Values.setVariable was negated with the not function.
{{ end }}
```
Now we can turn from functions and pipelines to flow control with conditions, loops, and scope modifiers.

Loading…
Cancel
Save