From 7fd367c26dcdbc229175a7bb9dea6cdce6ef1d15 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Thu, 1 Dec 2022 19:49:58 +0200 Subject: [PATCH] add storageclassname function --- .../templates/lib/util/_storageClassName.tpl | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 library/common/1.0.0/templates/lib/util/_storageClassName.tpl diff --git a/library/common/1.0.0/templates/lib/util/_storageClassName.tpl b/library/common/1.0.0/templates/lib/util/_storageClassName.tpl new file mode 100644 index 0000000000..5f1bd7fca1 --- /dev/null +++ b/library/common/1.0.0/templates/lib/util/_storageClassName.tpl @@ -0,0 +1,29 @@ +{{/* Returns the storageClassname */}} +{{- define "ix.v1.common.storage.storageClassName" -}} + {{- $persistence := .persistence -}} + {{- $root := .root -}} + + {{/* + If a storage class is defined on a persistence object: + "-" returns "", which means requesting a PV without class + SCALE-ZFS returns the value set on .Values.global.ixChartContext.storageClassName + else return the defined storageClass + Else if there is a storageClass defined in .Values.global.ixChartContext.storageClassName, return this + In any other case, return nothing + */}} + + {{- if $persistence.storageClass -}} + {{- if eq "-" $persistence.storageClass -}} + {{- print "\"\"" -}} + {{- else if eq "SCALE-ZFS" $persistence.storageClass -}} + {{- if not $root.Values.global.ixChartContext.storageClassName -}} + {{- fail "A storageClassName must be defined in global.ixChartContext.storageClassName" -}} + {{- end -}} + {{- print $root.Values.global.ixChartContext.storageClassName -}} + {{- else -}} + {{- print $persistence.storageClass -}} + {{- end -}} + {{- else if $root.Values.global.ixChartContext.storageClassName -}} + {{- print $root.Values.global.ixChartContext.storageClassName -}} + {{- end -}} +{{- end -}}