From 7c0a1d53c12d289a831b78bb250beca0df8d70a6 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Thu, 22 Dec 2022 13:27:22 +0200 Subject: [PATCH] check if a db-user exists in a secret and use that --- charts/nextcloud/1.6.15/templates/postgres-secret.yaml | 10 ++++++++++ test/nextcloud/1.6.15/templates/postgres-secret.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/charts/nextcloud/1.6.15/templates/postgres-secret.yaml b/charts/nextcloud/1.6.15/templates/postgres-secret.yaml index 48eb695f09..2ebc8b9b17 100644 --- a/charts/nextcloud/1.6.15/templates/postgres-secret.yaml +++ b/charts/nextcloud/1.6.15/templates/postgres-secret.yaml @@ -4,7 +4,17 @@ kind: Secret metadata: name: {{ $secretName }} data: + {{/* + Lookup for the user shouldn't be needed in normal circumstances + But there was a typo before that resulted to a db-user with weird + characters. So to keep that user for existing installations we retrieve + it from the existing secret. + */}} + {{ with (lookup "v1" "Secret" .Release.Namespace $secretName)}} + db-user: {{ index .data "db-user" }} + {{ else }} db-user: {{ (include "postgres.DatabaseName" .Values ) | b64enc }} + {{ end }} {{ with (lookup "v1" "Secret" .Release.Namespace $secretName) }} db-password: {{ index .data "db-password" }} {{ else }} diff --git a/test/nextcloud/1.6.15/templates/postgres-secret.yaml b/test/nextcloud/1.6.15/templates/postgres-secret.yaml index 48eb695f09..2ebc8b9b17 100644 --- a/test/nextcloud/1.6.15/templates/postgres-secret.yaml +++ b/test/nextcloud/1.6.15/templates/postgres-secret.yaml @@ -4,7 +4,17 @@ kind: Secret metadata: name: {{ $secretName }} data: + {{/* + Lookup for the user shouldn't be needed in normal circumstances + But there was a typo before that resulted to a db-user with weird + characters. So to keep that user for existing installations we retrieve + it from the existing secret. + */}} + {{ with (lookup "v1" "Secret" .Release.Namespace $secretName)}} + db-user: {{ index .data "db-user" }} + {{ else }} db-user: {{ (include "postgres.DatabaseName" .Values ) | b64enc }} + {{ end }} {{ with (lookup "v1" "Secret" .Release.Namespace $secretName) }} db-password: {{ index .data "db-password" }} {{ else }}