[COMMON] Enhancements on common templates 81/115481/11
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>
Fri, 27 Nov 2020 10:06:10 +0000 (11:06 +0100)
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>
Wed, 9 Dec 2020 07:49:48 +0000 (07:49 +0000)
It's a collection of small enhancements for common templates.

Issue-ID: OOM-1720
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: I426f7aed05ea7e94899b9e4888f4e4c66b69cb53

kubernetes/common/common/templates/_labels.tpl
kubernetes/common/common/templates/_mariadb.tpl

index 6672762..da8f00f 100644 (file)
@@ -30,7 +30,7 @@ app.kubernetes.io/instance: {{ include "common.release" $dot }}
 app.kubernetes.io/managed-by: {{ $dot.Release.Service }}
 {{ if .labels }}
 {{- include "common.tplValue" (dict "value" .labels "context" $dot) }}
-{{- end -}}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -41,14 +41,15 @@ The function takes several arguments (inside a dictionary):
 */}}
 {{- define "common.matchLabels" -}}
 {{- $dot := default . .dot -}}
-{{- if not .matchLabels.nameNoMatch -}}
+{{- $matchLabels := default (dict) .matchLabels -}}
+{{- if not $matchLabels.nameNoMatch -}}
 app.kubernetes.io/name: {{ include "common.name" $dot }}
 {{- end }}
 app.kubernetes.io/instance: {{ include "common.release" $dot }}
-{{ if .matchLabels }}
-{{$_ := unset .matchLabels "nameNoMatch"}}
-{{- include "common.tplValue" (dict "value" .matchLabels "context" $dot) }}
-{{- end -}}
+{{- if $matchLabels }}
+{{$_ := unset $matchLabels "nameNoMatch"}}
+{{- include "common.tplValue" (dict "value" $matchLabels "context" $dot) }}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -69,7 +70,7 @@ namespace: {{ include "common.namespace" $dot }}
 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot ) | nindent 2 }}
 {{- if $annotations }}
 annotations:  {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}}
-{{- end -}}
+{{- end }}
 {{- end -}}
 
 {{/*
@@ -94,7 +95,7 @@ matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels "
 {{- $dot := default . .dot -}}
 {{- $labels := default (dict) .labels -}}
 {{- if $dot.Values.podAnnotations }}
-annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $) | nindent 2 }}
+annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $dot) | nindent 2 }}
 {{- end }}
 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot) | nindent 2 }}
 name: {{ include "common.name" $dot }}
index df0e6b4..1be3e3b 100644 (file)
   {{- printf "db-user-credentials" }}
 {{- end -}}
 
+{{/*
+  UID of mariadb backup credentials
+*/}}
+{{- define "common.mariadb.secret.backupCredentialsUID" -}}
+  {{- printf "db-backup-credentials" }}
+{{- end -}}
+
 {{/*
   Name of mariadb user credentials secret
 */}}