Skip to content

Chart Template Guide: Confusing statement about unnecessary conditional #1697

@windmueller

Description

@windmueller

The section Flow Control of the Chart Template Guide has this listing:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  myvalue: "Hello World"
  {{- with .Values.favorite }}
  drink: {{ .drink | default "tea" | quote }}
  food: {{ .food | upper | quote }}
  {{- end }}

In the next paragraph it states:

Note that we removed the if conditional from the previous exercise because it is now unnecessary - the block after with only executes if the value of PIPELINE is not empty.

However, the now omitted conditional was:

  {{- if eq .Values.favorite.drink "coffee" }}
  mug: "true"
  {{- end }}

That statement does not check if the value is empty but if .drink matches "coffee".

Has the example been changed without modifying the text or am I missing something here?

In my opinion the example should now be:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  myvalue: "Hello World"
  {{- with .Values.favorite }}
  drink: {{ .drink | default "tea" | quote }}
  food: {{ .food | upper | quote }}
  {{- if eq .drink "coffee" }}
  mug: true
  {{- end }}
  {{- end }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions