summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2020-01-09 21:53:55 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2020-02-01 00:10:01 +0100
commitb9c30534d9af126401e1d038de0d4cf6d78b001e (patch)
tree9f70886994cb0e2ddfea5ec777121bc508aa7120
parentd73224418141fb7a2bae8d083de8f6e88e493c3d (diff)
[COMMON] Allow to search secret by uid even if name is Overridden
In some cases it is useful to bypass default policy for secret name generation and provide a custom name for a secret. In this case current search implementation got confused and couln't find a secret based on uid. This patch fixes the issue by comaring not only name but also uid. Issue-ID: OOM-2246 Change-Id: Iaea7a23fee09aa388968aad792ba7f7e1fbf2f21 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r--kubernetes/common/common/templates/_secret.yaml9
1 files changed, 6 insertions, 3 deletions
diff --git a/kubernetes/common/common/templates/_secret.yaml b/kubernetes/common/common/templates/_secret.yaml
index 0aff3a647b..55cb9bb9c8 100644
--- a/kubernetes/common/common/templates/_secret.yaml
+++ b/kubernetes/common/common/templates/_secret.yaml
@@ -115,10 +115,13 @@ type: Opaque
*/}}
{{- define "common.secret.getSecretName" -}}
{{- $global := .global }}
- {{- $targetName := include "common.secret._genName" (dict "global" $global "uid" .uid "name" .name) }}
+ {{- $name := tpl (default "" .name) $global }}
+ {{- $uid := .uid }}
+ {{- $targetName := default (include "common.secret._genName" (dict "global" $global "uid" .uid "name" .name)) $name}}
{{- range $secret := $global.Values.secrets }}
- {{- $currName := include "common.secret._genName" (dict "global" $global "uid" $secret.uid "name" $secret.name) }}
- {{- if eq $currName $targetName }}
+ {{- $givenName := tpl (default "" $secret.name) $global }}
+ {{- $currName := default (include "common.secret._genName" (dict "global" $global "uid" $secret.uid "name" $secret.name)) $givenName }}
+ {{- if or (eq $uid $secret.uid) (eq $currName $targetName) }}
{{- $externalSecret := tpl (default "" $secret.externalSecret) $global }}
{{- default $currName $externalSecret }}
{{- end }}