From ee2e6dd89bbd36d94fe717923761ec9743bcab74 Mon Sep 17 00:00:00 2001 From: Zachariah Miller Date: Wed, 17 Jul 2024 13:38:23 -0400 Subject: [PATCH] fix: update secret templating to reuse existing as chart does not support updating credential --- chart/templates/password-secret.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/chart/templates/password-secret.yaml b/chart/templates/password-secret.yaml index c726f07..32f0a9a 100644 --- a/chart/templates/password-secret.yaml +++ b/chart/templates/password-secret.yaml @@ -1,11 +1,19 @@ -{{- $password := randAlphaNum 16 }} +{{- $namespace := .Release.Namespace }} +{{- $existingSecret := lookup "v1" "Secret" $namespace "valkey-password" }} +{{- $password := (randAlphaNum 16) }} +{{- if $existingSecret }} + {{- $decoded := index $existingSecret.data "valkey-password" | b64dec }} + {{- $password = $decoded }} +{{- end }} + apiVersion: v1 kind: Secret metadata: name: valkey-password - namespace: {{ .Release.Namespace }} + namespace: {{ $namespace }} stringData: - valkey-password: {{ printf "%s" $password | quote }} + valkey-password: {{ $password | quote }} + {{- if .Values.copyPassword.enabled }} --- apiVersion: v1 @@ -14,5 +22,6 @@ metadata: name: {{ .Values.copyPassword.secretName }} namespace: {{ .Values.copyPassword.namespace }} stringData: - {{ dict .Values.copyPassword.secretKey $password | toYaml }} + {{- $data := dict .Values.copyPassword.secretKey $password }} + {{- toYaml $data | nindent 2 }} {{- end }}