From 9293dfec5503c18f462e5321cecef4eb4fadaf57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Cabrera=20Mi=C3=B1agorri?= Date: Wed, 21 Aug 2019 19:05:01 +0200 Subject: [PATCH] [stable/opencart] Refactor StorageClass template to support old Helm versions (#16495) Signed-off-by: miguelaeh --- stable/opencart/Chart.yaml | 2 +- stable/opencart/templates/_helpers.tpl | 36 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/stable/opencart/Chart.yaml b/stable/opencart/Chart.yaml index d4977bd294..9082b21e66 100644 --- a/stable/opencart/Chart.yaml +++ b/stable/opencart/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: opencart -version: 6.1.0 +version: 6.1.1 appVersion: 3.0.3-2 description: A free and open source e-commerce platform for online merchants. It provides a professional and reliable foundation for a successful online store. keywords: diff --git a/stable/opencart/templates/_helpers.tpl b/stable/opencart/templates/_helpers.tpl index 29d60095b1..561987b099 100644 --- a/stable/opencart/templates/_helpers.tpl +++ b/stable/opencart/templates/_helpers.tpl @@ -144,19 +144,33 @@ imagePullSecrets: Return the proper Storage Class */}} {{- define "opencart.storageClass" -}} -{{- $storageClass := "" }} +{{/* +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 -}} - {{- else if .Values.persistence.opencart.storageClass -}} - {{- $storageClass = .Values.persistence.opencart.storageClass -}} + {{- if (eq "-" .Values.global.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.global.storageClass -}} + {{- end -}} + {{- else -}} + {{- if .Values.persistence.opencart.storageClass -}} + {{- if (eq "-" .Values.persistence.opencart.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.persistence.opencart.storageClass -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- else -}} + {{- if .Values.persistence.opencart.storageClass -}} + {{- if (eq "-" .Values.persistence.opencart.storageClass) -}} + {{- printf "\"\"" -}} + {{- else }} + {{- printf "%s" .Values.persistence.opencart.storageClass -}} + {{- end -}} {{- end -}} -{{- else if .Values.persistence.opencart.storageClass -}} - {{- $storageClass = .Values.persistence.opencart.storageClass -}} -{{- end -}} -{{- if (eq "-" $storageClass) -}} - {{- printf "\"\"" -}} -{{- else }} - {{- printf "%s" $storageClass -}} {{- end -}} {{- end -}}