[COMMON] Allow to attach annotations to secrets 69/103069/2
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 4 Mar 2020 22:04:21 +0000 (23:04 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 6 Mar 2020 13:33:40 +0000 (13:33 +0000)
SO adds some annotations to one of its secres so let's extend the
common secret template with the ability to add annotations.

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

kubernetes/common/common/templates/_secret.yaml

index e24a2e4..9f41906 100644 (file)
@@ -22,6 +22,7 @@
   The template takes two arguments:
     - .global: environment (.)
     - .name: name of the secret
+    - .annotations: annotations which should be used
 
   Example call:
     {{ include "common.secret._header" (dict "global" . "name" "myFancyName") }}
@@ -39,6 +40,9 @@ metadata:
     chart: {{ $global.Chart.Name }}-{{ $global.Chart.Version | replace "+" "_" }}
     release: {{ include "common.release" $global }}
     heritage: {{ $global.Release.Service }}
+{{- if .annotations }}
+  annotations: {{- include "common.tplValue" (dict "value" .annotations "context" $global) | nindent 4 }}
+{{- end }}
 type: Opaque
 {{- end -}}
 
@@ -204,6 +208,8 @@ valueFrom:
     - name:
         Overrides default secret name generation and allows to set immutable
         and globaly unique name
+    - annotations:
+        List of annotations to be used while defining a secret
 
   To allow sharing a secret between the components and allow to pre-deploy secrets
   before ONAP deployment it is possible to use already existing secret instead of
@@ -239,11 +245,12 @@ valueFrom:
   {{- range $secret := .Values.secrets }}
     {{- $uid := tpl (default "" $secret.uid) $global }}
     {{- $name := include "common.secret.genName" (dict "global" $global "uid" $uid "name" $secret.name) }}
+    {{- $annotations := default "" $secret.annotations }}
     {{- $type := default "generic" $secret.type }}
     {{- $externalSecret := tpl (default "" $secret.externalSecret) $global }}
     {{- if not $externalSecret }}
 ---
-      {{ include "common.secret._header" (dict "global" $global "name" $name) }}
+      {{ include "common.secret._header" (dict "global" $global "name" $name "annotations" $annotations) }}
 
       {{- if eq $type "generic" }}
 data: