Skip to content

Commit 79c7c99

Browse files
Make PG password static between upgrades (#76)
1 parent 0963504 commit 79c7c99

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

stable/yugaware/templates/_helpers.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,19 @@ Validate Nginx SSL protocols
8080
{{- .Values.tls.sslProtocols -}}
8181
{{- end -}}
8282
{{- end -}}
83+
84+
{{/*
85+
Get or generate PG password
86+
Source - https://github.com/helm/charts/issues/5167#issuecomment-843962731
87+
*/}}
88+
{{- define "getOrGeneratePassword" }}
89+
{{- $len := (default 8 .Length) | int -}}
90+
{{- $obj := (lookup "v1" .Kind .Namespace .Name).data -}}
91+
{{- if $obj }}
92+
{{- index $obj .Key -}}
93+
{{- else if (eq (lower .Kind) "secret") -}}
94+
{{- randAlphaNum $len | b64enc -}}
95+
{{- else -}}
96+
{{- randAlphaNum $len -}}
97+
{{- end -}}
98+
{{- end }}

stable/yugaware/templates/configs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
heritage: {{ .Values.helm2Legacy | ternary "Tiller" (.Release.Service | quote) }}
1212
data:
1313
postgres_user: "postgres"
14-
postgres_password: "{{ b64enc (randAlphaNum 8) }}"
14+
postgres_password: "{{ include "getOrGeneratePassword" (dict "Namespace" .Release.Namespace "Kind" "ConfigMap" "Name" (printf "%s%s" .Release.Name "-yugaware-global-config") "Key" "postgres_password") }}"
1515
postgres_db: "yugaware"
1616
app_secret: "{{ b64enc (randAlphaNum 64) }}"
1717

0 commit comments

Comments
 (0)