Skip to content

Commit

Permalink
fix(helm): reuse existing password or generate password during instal…
Browse files Browse the repository at this point in the history
…l as default and dont fail pipeline. (#1685)

Co-authored-by: Derek Roberts <[email protected]>
  • Loading branch information
mishraomp and DerekRoberts authored Dec 5, 2023
1 parent 7d2fc14 commit 1c705b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ concurrency:
jobs:
# Enforce conventional commits in PR titles
conventional-commits:
if: github.event_name == 'pull_request'
name: Conventional Commits
runs-on: ubuntu-22.04
steps:
Expand Down
16 changes: 10 additions & 6 deletions charts/quickstart-openshift/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- if and .Values.global.secrets .Values.global.secrets.enabled}}
{{- $databaseUser := .Values.global.secrets.databaseUser| default "quickstart" }}
{{- $databasePassword := .Values.global.secrets.databasePassword }}
{{- $databasePassword := .Values.global.secrets.databasePassword | default (randAlphaNum 10) | quote }}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace .Release.Name ) | default dict }}
{{- $secretData := (get $secretObj "data") | default dict }}
# set below to existing secret data or generate a random one when not exists
{{- $databasePassword = (get $secretData "databasePassword") | default ($databasePassword | b64enc) }}
{{- $databaseName := .Values.global.secrets.databaseName| default "quickstart" }}
{{- $host := printf "%s-%s:5432" .Release.Name .Values.global.databaseAlias }}
{{- $databaseURL := printf "postgresql://%s:%s@%s/%s" $databaseUser $databasePassword $host $databaseName }}
{{- $databaseJDBCURL := printf "jdbc:postgresql://%s:%s@%s/%s" $databaseUser $databasePassword $host $databaseName }}
{{- $databaseURL := printf "postgresql://%s:%s@%s/%s" $databaseUser (b64dec $databasePassword) $host $databaseName }}
{{- $databaseJDBCURL := printf "jdbc:postgresql://%s:%s@%s/%s" $databaseUser (b64dec $databasePassword) $host $databaseName }}
{{- $databaseJDBCURLNoCreds := printf "jdbc:postgresql://%s/%s" $host $databaseName }}
---
apiVersion: v1
Expand All @@ -13,9 +17,9 @@ metadata:
name: {{ .Release.Name }}
labels: {{- include "selectorLabels" . | nindent 4 }}
data:
databasePassword: {{ $databasePassword | b64enc | quote }}
postgres-password: {{ $databasePassword | b64enc | quote }}
password: {{ $databasePassword | b64enc | quote }}
databasePassword: {{ $databasePassword | quote }}
postgres-password: {{ $databasePassword | quote }}
password: {{ $databasePassword | quote }}
databaseUser: {{ $databaseUser | b64enc | quote }}
databaseName: {{ $databaseName | b64enc | quote }}
databaseURL: {{ $databaseURL | b64enc | quote }}
Expand Down

0 comments on commit 1c705b3

Please sign in to comment.