make sure to use the same encryption keys

This commit is contained in:
stremovsky
2022-01-05 13:20:40 +02:00
parent 4ff7a90cb1
commit a0779fcaf9

View File

@@ -8,19 +8,42 @@ metadata:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if .Values.databunkerMasterkey }}
databunker-masterkey: {{ default "" .Values.databunkerMasterkey | b64enc | quote }}
{{- else }}
databunker-masterkey: {{ substr 1 49 (printf "%x%x%x%x%x%x" (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) ) | b64enc | quote }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace ( include "common.names.fullname" .) ) }}
{{- $databunkerMasterkey := "" }}
{{- if $secret }}
{{- if index $secret.data "databunker-masterkey" }}
{{- $databunkerMasterkey = index $secret.data "databunker-masterkey" }}
{{- end }}
{{- end }}
{{- if .Values.databunkerRoottoken }}
databunker-roottoken: {{ default "" .Values.databunkerRoottoken | b64enc | quote }}
{{- else }}
databunker-roottoken: {{ uuidv4 | b64enc | quote }}
{{- if not $databunkerMasterkey }}
{{- if .Values.databunkerMasterkey }}
{{- $databunkerMasterkey = .Values.databunkerMasterkey | b64enc | quote }}
{{- else }}
{{- $databunkerMasterkey = substr 1 49 (printf "%x%x%x%x%x%x" (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) (int64 (randNumeric 18)) ) | b64enc | quote }}
{{- end }}
{{- end }}
databunker-masterkey: {{ $databunkerMasterkey }}
{{- $databunkerRoottoken := "" }}
{{- if $secret }}
{{- if index $secret.data "databunker-roottoken" }}
{{- $databunkerRoottoken = index $secret.data "databunker-roottoken" }}
{{- end }}
{{- end }}
{{- if not $databunkerRoottoken }}
{{- if .Values.databunkerRoottoken }}
{{- $databunkerRoottoken = .Values.databunkerRoottoken | b64enc | quote }}
{{- else }}
{{- $databunkerRoottoken = uuidv4 | b64enc | quote }}
{{- end }}
{{- end }}
databunker-roottoken: {{ $databunkerRoottoken }}
{{- end }}