From 9af60e3f03d6a0197cbffd219303e6d6891157c6 Mon Sep 17 00:00:00 2001 From: hadams95 Date: Wed, 20 Mar 2024 21:30:27 -0400 Subject: [PATCH] simplify dbcreds fallbacks --- helm/common/templates/_db_setup_job.tpl | 48 +++++++------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/helm/common/templates/_db_setup_job.tpl b/helm/common/templates/_db_setup_job.tpl index 38313dc1..46f54dea 100644 --- a/helm/common/templates/_db_setup_job.tpl +++ b/helm/common/templates/_db_setup_job.tpl @@ -59,66 +59,42 @@ spec: name: {{ .Release.Name }}-postgresql key: postgres-password optional: false - {{- else if .Values.externalSecrets.dbcreds }} + {{- else if or .Values.externalSecrets.dbcreds $.Values.global.postgres.externalSecret }} valueFrom: secretKeyRef: - name: {{ .Values.externalSecrets.dbcreds }} - key: password - optional: false - {{- else if $.Values.global.postgres.externalSecret }} - valueFrom: - secretKeyRef: - name: {{ $.Values.global.postgres.externalSecret }} + name: {{ .Values.externalSecrets.dbcreds | default $.Values.global.postgres.externalSecret }} key: password optional: false {{- else }} value: {{ .Values.global.postgres.master.password | quote}} {{- end }} - name: PGUSER - {{- if .Values.externalSecrets.dbcreds }} - valueFrom: - secretKeyRef: - name: {{ .Values.externalSecrets.dbcreds }} - key: username - optional: false - {{- else if $.Values.global.postgres.externalSecret }} + {{- if or .Values.externalSecrets.dbcreds $.Values.global.postgres.externalSecret }} valueFrom: secretKeyRef: - name: {{ $.Values.global.postgres.externalSecret }} + name: {{ .Values.externalSecrets.dbcreds | default $.Values.global.postgres.externalSecret }} key: username optional: false - {{- else }} + {{- else }} value: {{ .Values.global.postgres.master.username | quote }} - {{- end }} + {{- end }} - name: PGPORT - {{- if .Values.externalSecrets.dbcreds }} + {{- if or .Values.externalSecrets.dbcreds $.Values.global.postgres.externalSecret }} valueFrom: secretKeyRef: - name: {{ .Values.externalSecrets.dbcreds }} + name: {{ .Values.externalSecrets.dbcreds | default $.Values.global.postgres.externalSecret }} key: port optional: false - {{- else if $.Values.global.postgres.externalSecret }} - valueFrom: - secretKeyRef: - name: {{ $.Values.global.postgres.externalSecret }} - key: port - optional: false - {{- else }} + {{- else }} value: {{ .Values.global.postgres.master.port | quote }} - {{- end }} + {{- end }} - name: PGHOST {{- if $.Values.global.dev }} value: "{{ .Release.Name }}-postgresql" - {{- else if .Values.externalSecrets.dbcreds }} - valueFrom: - secretKeyRef: - name: {{ .Values.externalSecrets.dbcreds }} - key: host - optional: false - {{- else if $.Values.global.postgres.externalSecret }} + {{- else if or .Values.externalSecrets.dbcreds $.Values.global.postgres.externalSecret }} valueFrom: secretKeyRef: - name: {{ $.Values.global.postgres.externalSecret }} + name: {{ .Values.externalSecrets.dbcreds | default $.Values.global.postgres.externalSecret }} key: host optional: false {{- else }}