From: Krzysztof Opasiak Date: Tue, 21 Jan 2020 23:03:45 +0000 (+0100) Subject: [COMMON] Expose common.secret.genName template X-Git-Tag: 6.0.0~419^2~7 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=fd6676f06becc509961d8a9a06b60168e4884349;p=oom.git [COMMON] Expose common.secret.genName template This template used to be for internal use only but it turned out to be very useful in number of places so let's just expose it. Issue-ID: OOM-2249 Change-Id: I57cd31681fb5edb4ac95b0b7b2446a364ce826d2 Signed-off-by: Krzysztof Opasiak --- diff --git a/kubernetes/common/common/templates/_secret.yaml b/kubernetes/common/common/templates/_secret.yaml index 55cb9bb9c8..e24a2e4ba7 100644 --- a/kubernetes/common/common/templates/_secret.yaml +++ b/kubernetes/common/common/templates/_secret.yaml @@ -76,8 +76,6 @@ type: Opaque {{/* - For internal use only! - Generate a secret name based on provided name or UID. If UID is provided then the name is generated by appending this UID right after the chart name. If name is provided, it overrides the name generation algorith @@ -90,11 +88,12 @@ type: Opaque - .name: string that can be used to override default name generation algorithm and provide a custom name for the secret */}} -{{- define "common.secret._genName" -}} +{{- define "common.secret.genName" -}} {{- $global := .global }} {{- $uid := tpl (default "" .uid) $global }} {{- $name := tpl (default "" .name) $global }} - {{- default (printf "%s-%s" (include "common.fullname" $global) $uid) $name }} + {{- $fullname := ne (default "" .chartName) "" | ternary (include "common.fullnameExplicit" (dict "dot" $global "chartName" .chartName)) (include "common.fullname" $global) }} + {{- default (printf "%s-%s" $fullname $uid) $name }} {{- end -}} {{/* @@ -116,12 +115,13 @@ type: Opaque {{- define "common.secret.getSecretName" -}} {{- $global := .global }} {{- $name := tpl (default "" .name) $global }} - {{- $uid := .uid }} - {{- $targetName := default (include "common.secret._genName" (dict "global" $global "uid" .uid "name" .name)) $name}} + {{- $uid := tpl (default "" .uid) $global }} + {{- $targetName := default (include "common.secret.genName" (dict "global" $global "uid" $uid "name" .name)) $name}} {{- range $secret := $global.Values.secrets }} {{- $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) }} + {{- $currUID := tpl (default "" $secret.uid) $global }} + {{- $currName := default (include "common.secret.genName" (dict "global" $global "uid" $currUID "name" $secret.name)) $givenName }} + {{- if or (eq $uid $currUID) (eq $currName $targetName) }} {{- $externalSecret := tpl (default "" $secret.externalSecret) $global }} {{- default $currName $externalSecret }} {{- end }} @@ -237,7 +237,8 @@ valueFrom: {{- define "common.secret" -}} {{- $global := . }} {{- range $secret := .Values.secrets }} - {{- $name := include "common.secret._genName" (dict "global" $global "uid" $secret.uid "name" $secret.name) }} + {{- $uid := tpl (default "" $secret.uid) $global }} + {{- $name := include "common.secret.genName" (dict "global" $global "uid" $uid "name" $secret.name) }} {{- $type := default "generic" $secret.type }} {{- $externalSecret := tpl (default "" $secret.externalSecret) $global }} {{- if not $externalSecret }}