22Reusable snippets shared across Vela Helm templates.
33*/ }}
44
5+ {{/*
6+ Returns the plaintext password for a given DB credential key, preserving it across upgrades
7+ via lookup of the existing vela-controller-secret. On fresh installs the password is derived
8+ deterministically from the release name, namespace, and key so that all templates in the same
9+ render produce the same value.
10+
11+ Usage: {{ include "vela.dbPassword" (list "controller-db-password" .) }}
12+ */ }}
13+ {{- define " vela.dbPassword" -}}
14+ {{- $key := index . 0 -}}
15+ {{- $ctx := index . 1 -}}
16+ {{- $existingSecret := lookup " v1" " Secret" $ctx .Release.Namespace " vela-controller-secret" -}}
17+ {{- if and $existingSecret (index $existingSecret .data $key ) -}}
18+ {{- index $existingSecret .data $key | b64dec -}}
19+ {{- else -}}
20+ {{- printf " %s -%s -%s " $ctx .Release.Name $ctx .Release.Namespace $key | sha256sum | trunc 32 -}}
21+ {{- end -}}
22+ {{- end -}}
23+
524{{/*
625Renders a Postgres init container that waits for the target database to accept connections.
726The helper accepts a dictionary with the following optional keys:
@@ -13,6 +32,7 @@ The helper accepts a dictionary with the following optional keys:
1332 - secretName : Kubernetes secret with credentials (default: database)
1433 - usernameKey : Secret key used for DB username (default: superuser-username)
1534 - passwordKey : Secret key used for DB password (default: superuser-password)
35+ - database : database name to verify connectivity (default: controller)
1636 - securityContext : optional security context applied to the init container
1737*/ }}
1838{{- define " vela.waitForPostgresInitContainer" -}}
@@ -24,6 +44,7 @@ The helper accepts a dictionary with the following optional keys:
2444{{- $secretName := default " database" .secretName -}}
2545{{- $usernameKey := default " superuser-username" .usernameKey -}}
2646{{- $passwordKey := default " superuser-password" .passwordKey -}}
47+ {{- $database := default " controller" .database -}}
2748- name: {{ $name }}
2849 image: {{ $image }}
2950 imagePullPolicy: {{ $imagePullPolicy }}
@@ -51,9 +72,8 @@ The helper accepts a dictionary with the following optional keys:
5172 done
5273 echo " Database is ready"
5374
54- # Ensure postgres user can connect
55- until psql -h " $DB_HOST" -U " $DB_USER" -d postgres -c '\q' 2>/dev/null; do
56- echo " Waiting for Postgres superuser connection..."
75+ until psql -h " $DB_HOST" -U " $DB_USER" -d {{ $database | quote }} -c '\q' 2>/dev/null; do
76+ echo " Waiting for Postgres connection to {{ $database }}..."
5777 sleep 2
5878 done
5979{{- with .securityContext }}
0 commit comments