33 lines
1.1 KiB
YAML
33 lines
1.1 KiB
YAML
|
|
{{/*
|
|
Secret initializer and data maintainer
|
|
This helper will initialize the secret data with "initial" value if the secret is not found in the secret object.
|
|
IF the secret is found in the secret object, it will use the set value from the secret object thereby maintaining the secret data.
|
|
*/}}
|
|
{{- define "helper.secrets" -}}
|
|
{{- $secretObj := (lookup "v1" "Secret" .release.Namespace .component.name) | default dict }}
|
|
{{- range $key, $value := .component.secrets }}
|
|
{{- if empty $value -}}
|
|
{{- $secretData := (get $secretObj "data") | default dict }}
|
|
{{- $secret := (get $secretData $key) | default ("initial" | b64enc) }}
|
|
{{ $key }}: {{ $secret | quote }}
|
|
{{- else }}
|
|
{{ $key }}: {{ $value | b64enc | quote }}
|
|
{{- end -}}
|
|
{{- end }}
|
|
{{- end -}}
|
|
|
|
{{- range $system, $settings := .Values.components -}}
|
|
{{ if $settings.secrets }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: {{ $settings.name }}
|
|
labels:
|
|
{{ include "helper.metaLabels" (dict "component" $settings "values" $.Values) | indent 4 }}
|
|
type: Opaque
|
|
data:
|
|
{{- include "helper.secrets" (dict "component" $settings "release" $.Release) }}
|
|
{{- end }}
|
|
{{- end }} |