From b9c30534d9af126401e1d038de0d4cf6d78b001e Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Thu, 9 Jan 2020 21:53:55 +0100 Subject: [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 --- kubernetes/common/common/templates/_secret.yaml | 9 ++++++--- 1 file 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 }} -- cgit 1.2.3-korg