From 6311fce06c11ce21c5c3edabf68b71fff88c027c Mon Sep 17 00:00:00 2001 From: Gerrit-K Date: Thu, 16 Nov 2023 16:48:36 +0100 Subject: [PATCH] feat(sql): allow providing username from secret for sql setup jobs (#380) See #291 --- charts/datahub/Chart.yaml | 2 +- charts/datahub/templates/mysql-setup-job.yml | 10 +++++++++- charts/datahub/templates/postgresql-setup-job.yml | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/charts/datahub/Chart.yaml b/charts/datahub/Chart.yaml index 5da20cabf..61a65e84b 100644 --- a/charts/datahub/Chart.yaml +++ b/charts/datahub/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for LinkedIn DataHub type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.3.9 +version: 0.3.10 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: 0.11.0 diff --git a/charts/datahub/templates/mysql-setup-job.yml b/charts/datahub/templates/mysql-setup-job.yml index e847726ae..a36c83159 100644 --- a/charts/datahub/templates/mysql-setup-job.yml +++ b/charts/datahub/templates/mysql-setup-job.yml @@ -53,7 +53,15 @@ spec: imagePullPolicy: {{ .Values.mysqlSetupJob.image.pullPolicy | default "IfNotPresent" }} env: - name: MYSQL_USERNAME - value: {{ .Values.mysqlSetupJob.username | default .Values.global.sql.datasource.username | quote }} + {{- $usernameValue := (.Values.mysqlSetupJob).username | default .Values.global.sql.datasource.username }} + {{- if and (kindIs "string" $usernameValue) $usernameValue }} + value: {{ $usernameValue | quote }} + {{- else }} + valueFrom: + secretKeyRef: + name: "{{ ($usernameValue).secretRef | default .Values.global.sql.datasource.username.secretRef }}" + key: "{{ ($usernameValue).secretKey | default .Values.global.sql.datasource.username.secretKey }}" + {{- end }} - name: MYSQL_PASSWORD {{- $passwordValue := (.Values.mysqlSetupJob.password).value | default .Values.global.sql.datasource.password.value }} {{- if $passwordValue }} diff --git a/charts/datahub/templates/postgresql-setup-job.yml b/charts/datahub/templates/postgresql-setup-job.yml index f5c021468..e40822465 100644 --- a/charts/datahub/templates/postgresql-setup-job.yml +++ b/charts/datahub/templates/postgresql-setup-job.yml @@ -53,7 +53,15 @@ spec: imagePullPolicy: {{ .Values.postgresqlSetupJob.image.pullPolicy | default "Always" }} env: - name: POSTGRES_USERNAME - value: {{ .Values.postgresqlSetupJob.username | default .Values.global.sql.datasource.username | quote }} + {{- $usernameValue := (.Values.postgresqlSetupJob).username | default .Values.global.sql.datasource.username }} + {{- if and (kindIs "string" $usernameValue) $usernameValue }} + value: {{ $usernameValue | quote }} + {{- else }} + valueFrom: + secretKeyRef: + name: "{{ ($usernameValue).secretRef | default .Values.global.sql.datasource.username.secretRef }}" + key: "{{ ($usernameValue).secretKey | default .Values.global.sql.datasource.username.secretKey }}" + {{- end }} - name: POSTGRES_PASSWORD {{- $passwordValue := (.Values.postgresqlSetupJob.password).value | default .Values.global.sql.datasource.password.value }} {{- if $passwordValue }}