[COMMON] Fix genericKV cache generation 32/124432/1
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 22 Sep 2021 18:44:49 +0000 (20:44 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 22 Sep 2021 18:46:16 +0000 (20:46 +0200)
Make sure that the envs sections gets tpl and cached properly.

Issue-ID: OOM-1
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Change-Id: I4064bdf3204a61a30b7296503c99e7931bae8cd2

kubernetes/common/common/templates/_secret.tpl

index 2490deb..9d284de 100644 (file)
@@ -193,7 +193,7 @@ type: Opaque
       {{- $entry := dict }}
       {{- $uid := tpl (default "" $secret.uid) $global }}
       {{- $keys := keys $secret }}
-      {{- range $key := (without $keys "annotations" "filePaths" )}}
+      {{- range $key := (without $keys "annotations" "filePaths" "envs" )}}
         {{- $_ := set $entry $key (tpl (index $secret $key) $global) }}
       {{- end }}
       {{- if $secret.annotations }}
@@ -213,12 +213,21 @@ type: Opaque
           {{- $_ := set $entry "filePaths" $secret.filePaths }}
         {{- end }}
       {{- end }}
+      {{- if $secret.envs }}
+        {{- $envsCache := (list) }}
+        {{- range $env := $secret.envs }}
+          {{- $tplValue := tpl (default "" $env.value) $global }}
+          {{- $envsCache = append $envsCache (dict "name" $env.name "policy" $env.policy "value" $tplValue) }}
+        {{- end }}
+        {{- $_ := set $entry "envs" $envsCache }}
+      {{- end }}
       {{- $realName := default (include "common.secret.genNameFast" (dict "global" $global "uid" $uid "name" $entry.name) ) $entry.externalSecret }}
       {{- $_ := set $entry "realName" $realName }}
       {{- $_ := set $secretCache $uid $entry }}
     {{- end }}
     {{- $_ := set $global.Values "_secretsCache" $secretCache }}
   {{- end }}
+
 {{- end -}}
 
 {{/*