From 0e792804151f8f722e91b39a2eb273ef84f40dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Cabrera=20Mi=C3=B1agorri?= Date: Wed, 21 Aug 2019 15:07:18 +0200 Subject: [PATCH] [stable/mongodb] Refactor StorageClass template to support old Helm versions (#16507) Signed-off-by: miguelaeh --- stable/mongodb/Chart.yaml | 2 +- stable/mongodb/templates/_helpers.tpl | 35 +++++++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/stable/mongodb/Chart.yaml b/stable/mongodb/Chart.yaml index 63d2659667..8ec9df8f3f 100644 --- a/stable/mongodb/Chart.yaml +++ b/stable/mongodb/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: mongodb -version: 7.2.0 +version: 7.2.1 appVersion: 4.0.12 description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. keywords: diff --git a/stable/mongodb/templates/_helpers.tpl b/stable/mongodb/templates/_helpers.tpl index b1a235d359..89c1d9b6bc 100644 --- a/stable/mongodb/templates/_helpers.tpl +++ b/stable/mongodb/templates/_helpers.tpl @@ -195,18 +195,33 @@ mongodb: mongodbUsername, mongodbDatabase Return the proper Storage Class */}} {{- define "mongodb.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 -}}