helm-charts/charts/library/common/templates/classes/_secret.tpl
2024-05-23 14:20:40 +02:00

45 lines
1.3 KiB
Smarty

{{/*
This template serves as a blueprint for all Secret objects that are created
within the common library.
*/}}
{{- define "bjw-s.common.class.secret" -}}
{{- $rootContext := .rootContext -}}
{{- $secretObject := .object -}}
{{- $labels := merge
($secretObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}}
{{- $annotations := merge
($secretObject.annotations | default dict)
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml)
-}}
{{- $stringData := "" -}}
{{- with $secretObject.stringData -}}
{{- $stringData = (toYaml $secretObject.stringData) | trim -}}
{{- end -}}
---
apiVersion: v1
kind: Secret
{{- with $secretObject.type }}
type: {{ . }}
{{- end }}
metadata:
name: {{ $secretObject.name }}
{{- with $labels }}
labels:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }}
{{- with $annotations }}
annotations:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }}
{{- with $stringData }}
stringData: {{- tpl $stringData $rootContext | nindent 2 }}
{{- end }}
{{- end -}}