Unverified Commit 777d9be0 authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #4278 from jonk/template-docs-bad-nil-compare

Add check for nil in template control structure tutorial 
parents e577d55b b3c583b8
...@@ -53,10 +53,10 @@ data: ...@@ -53,10 +53,10 @@ data:
myvalue: "Hello World" myvalue: "Hello World"
drink: {{ .Values.favorite.drink | default "tea" | quote }} drink: {{ .Values.favorite.drink | default "tea" | quote }}
food: {{ .Values.favorite.food | upper | quote }} food: {{ .Values.favorite.food | upper | quote }}
{{ if eq .Values.favorite.drink "coffee" }}mug: true{{ end }} {{ if (.Values.favorite.drink) and eq .Values.favorite.drink "coffee" }}mug: true{{ end }}
``` ```
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: 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:
```yaml ```yaml
# Source: mychart/templates/configmap.yaml # Source: mychart/templates/configmap.yaml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment