From b3c583b855f0c10bc3adb2a4f019e0e752643d83 Mon Sep 17 00:00:00 2001 From: Jon Kalfayan Date: Wed, 27 Jun 2018 21:31:40 -0700 Subject: [PATCH] add nil check in if statement configmap example, also note why --- docs/chart_template_guide/control_structures.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/chart_template_guide/control_structures.md b/docs/chart_template_guide/control_structures.md index 7575ebc35..1844bd393 100644 --- a/docs/chart_template_guide/control_structures.md +++ b/docs/chart_template_guide/control_structures.md @@ -53,10 +53,10 @@ data: myvalue: "Hello World" drink: {{ .Values.favorite.drink | default "tea" | 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 # Source: mychart/templates/configmap.yaml