-
Notifications
You must be signed in to change notification settings - Fork 476
Clarification: nil vs empty string #53
Copy link
Copy link
Closed
Description
Hello!
While reviewing recent charts PRs (example: helm/charts#2004), I see this interesting pattern:
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}The explanation is:
## mariadb data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"My question was, since the template-rendered YAML will either be a storage class name, an empty string (to disable dynamic provisioning), or not set at all, can't we just do this instead?
## mariadb data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to empty string "", this disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: ""Then the template logic could be simplified to:
{{- if .Values.persistence.storageClass }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}But this would only work if an empty string is different from not set (nil) when checking if .Values.some.value in go template. Can someone help clarify this for me, or point to the relevant part of the docs? I seem to not be able to find this info.
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels