From 549ee9f7481f33a96b952b2e8dd9eb349d2b941f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Cabrera=20Mi=C3=B1agorri?= Date: Wed, 21 Aug 2019 18:31:16 +0200 Subject: [PATCH] [stable/moodle] Refactor StorageClass template to support old Helm versions (#16493) Signed-off-by: miguelaeh --- stable/moodle/Chart.yaml | 2 +- stable/moodle/templates/_helpers.tpl | 35 ++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/stable/moodle/Chart.yaml b/stable/moodle/Chart.yaml index 770df1012e..e3fb330b81 100644 --- a/stable/moodle/Chart.yaml +++ b/stable/moodle/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: moodle -version: 6.1.0 +version: 6.1.1 appVersion: 3.7.1 description: Moodle is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments keywords: diff --git a/stable/moodle/templates/_helpers.tpl b/stable/moodle/templates/_helpers.tpl index b77edcbd22..111084053e 100644 --- a/stable/moodle/templates/_helpers.tpl +++ b/stable/moodle/templates/_helpers.tpl @@ -132,18 +132,33 @@ imagePullSecrets: Return the proper Storage Class */}} {{- define "moodle.storageClass" -}} -{{- $storageClass := "" }} -{{- if .Values.persistence.storageClass -}} - {{- $storageClass = .Values.persistence.storageClass -}} -{{- end -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic. +*/}} {{- if .Values.global -}} {{- if .Values.global.storageClass -}} - {{- $storageClass = .Values.global.storageClass -}} + {{- if (eq "-" .Values.global.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.global.storageClass -}} + {{- end -}} + {{- else -}} + {{- if .Values.persistence.storageClass -}} + {{- if (eq "-" .Values.persistence.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.persistence.storageClass -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- else -}} + {{- if .Values.persistence.storageClass -}} + {{- if (eq "-" .Values.persistence.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.persistence.storageClass -}} + {{- end -}} {{- end -}} {{- end -}} -{{- if (eq "-" $storageClass) -}} - {{- printf "\"\"" -}} -{{- else }} - {{- printf "%s" $storageClass -}} -{{- end -}} {{- end -}}