From cebe98f067f555c0712efc980e090a10732330ea Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Sun, 5 Mar 2023 14:30:22 +0100 Subject: [PATCH] feat(common): allow tpl for env expandObjectName, configmap-name and secret-name --- library/common/Chart.yaml | 2 +- library/common/templates/lib/container/_env.tpl | 3 +++ library/common/templates/lib/container/_envFrom.tpl | 9 +++++---- library/common/templates/spawner/_configmap.tpl | 10 +++++++++- library/common/templates/spawner/_secret.tpl | 10 +++++++++- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index d02169b7..39f1e65f 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.2.12 +version: 12.2.13 diff --git a/library/common/templates/lib/container/_env.tpl b/library/common/templates/lib/container/_env.tpl index 7e1376bd..8a1c5911 100644 --- a/library/common/templates/lib/container/_env.tpl +++ b/library/common/templates/lib/container/_env.tpl @@ -38,8 +38,11 @@ objectData: The object data to be used to render the container. key: {{ $obj.key | quote }} {{- $name = tpl $obj.name $rootCtx -}} + {{- if kindIs "bool" $obj.expandObjectName -}} {{- $expandName = $obj.expandObjectName -}} + {{- else if eq $obj.expandObjectName "false" -}} + {{- $expandName = false -}} {{- end -}} {{- if $expandName -}} diff --git a/library/common/templates/lib/container/_envFrom.tpl b/library/common/templates/lib/container/_envFrom.tpl index cba60a64..f0b30a79 100644 --- a/library/common/templates/lib/container/_envFrom.tpl +++ b/library/common/templates/lib/container/_envFrom.tpl @@ -26,10 +26,11 @@ objectData: The object data to be used to render the container. {{- $objectName := tpl .name $rootCtx -}} - {{- $expandName := true -}} - {{- if kindIs "bool" .expandObjectName -}} - {{- $expandName = .expandObjectName -}} - {{- end -}} + {{- if kindIs "bool" .expandObjectName -}} + {{- $expandName = .expandObjectName -}} + {{- else if eq .expandObjectName "false" -}} + {{- $expandName = false -}} + {{- end -}} {{- if $expandName -}} {{- $object := dict -}} diff --git a/library/common/templates/spawner/_configmap.tpl b/library/common/templates/spawner/_configmap.tpl index 72d6b0c6..af5b94dd 100644 --- a/library/common/templates/spawner/_configmap.tpl +++ b/library/common/templates/spawner/_configmap.tpl @@ -7,7 +7,15 @@ {{- range $name, $configmap := .Values.configmap -}} - {{- if $configmap.enabled -}} + {{- $enabled := false -}} + + {{- if kindIs "bool" $configmap.enabled -}} + {{- $enabled = $configmap.enabled -}} + {{- else if eq $configmap.enabled "true" -}} + {{- $enabled = true -}} + {{- end -}} + + {{- if $enabled -}} {{/* Create a copy of the configmap */}} {{- $objectData := (mustDeepCopy $configmap) -}} diff --git a/library/common/templates/spawner/_secret.tpl b/library/common/templates/spawner/_secret.tpl index 694a7841..96e3ae71 100644 --- a/library/common/templates/spawner/_secret.tpl +++ b/library/common/templates/spawner/_secret.tpl @@ -7,7 +7,15 @@ {{- range $name, $secret := .Values.secret -}} - {{- if $secret.enabled -}} + {{- $enabled := false -}} + + {{- if kindIs "bool" $secret.enabled -}} + {{- $enabled = $secret.enabled -}} + {{- else if eq $secret.enabled "true" -}} + {{- $enabled = true -}} + {{- end -}} + + {{- if $enabled -}} {{/* Create a copy of the secret */}} {{- $objectData := (mustDeepCopy $secret) -}}