Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions charts/app/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{{- if and .Values.global.secrets .Values.global.secrets.enabled }}
{{- $databaseUser := printf "" }}
{{- $databasePassword := printf "" }}
{{- $host := printf "" }}
{{- $databaseName := printf "" }}
{{- $hostWithoutPort := printf "" }}
{{- $pgbouncerUrl := printf "" }}
{{- if and .Values.global.secrets .Values.global.secrets.enabled}}
{{- $databaseUser := printf ""}}
{{- $databasePassword := printf ""}}
{{- $host := printf ""}}
{{- $databaseName := printf ""}}
{{- $hostWithoutPort := printf ""}}
{{- $pgbouncerUrl := printf ""}}
{{- $secretName := printf "%s-pguser-%s" .Values.global.databaseAlias .Values.global.config.databaseUser }}

{{- $databaseUser = .Values.global.config.databaseUser }}
{{- $databaseUser = .Values.global.config.databaseUser}}
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $secretName ) }}
{{- $secretData := (and $secretObj (get $secretObj "data")) }}

{{- if not (and $secretObj $secretData) }}
# NOTE: Secret '{{ $secretName }}' or its 'data' section not found in namespace '{{ .Release.Namespace }}'. Dependent Secret resources will not be rendered.
{{- if not $secretObj }}
{{- fail (printf "Secret %s not found in namespace %s" $secretName .Release.Namespace) }}
{{- end }}

{{- if and $secretObj $secretData }}

{{- $databasePassword = get $secretData "password" }}
{{- $secretData := (get $secretObj "data") }}
{{- if not $secretData }}
{{- fail (printf "Secret %s data not found in namespace %s" $secretName .Release.Namespace) }}
{{- end }}
{{- $databasePassword = get $secretData "password" }}
{{- $databaseName = b64dec (get $secretData "dbname") }}
{{- $pgbouncerUrl = b64dec (get $secretData "pgbouncer-uri") }}
{{- $host = printf "%s:%s" (b64dec (get $secretData "host")) (b64dec (get $secretData "port")) }}
{{- $hostWithoutPort = printf "%s" (b64dec (get $secretData "host")) }}
{{- $hostWithoutPort = printf "%s" (b64dec (get $secretData "host")) }}
{{- $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 }}
Expand Down Expand Up @@ -57,5 +55,3 @@ data:
FLYWAY_USER: {{ $databaseUser | b64enc | quote }}
FLYWAY_PASSWORD: {{ $databasePassword | quote }}
{{- end }}

{{- end }}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
ports: ["5432:5432"]

migrations:
image: flyway/flyway:12-alpine
image: flyway/flyway:11-alpine
container_name: migrations
command: info migrate info
volumes: ["./migrations/sql:/flyway/sql:ro"]
Expand Down
2 changes: 1 addition & 1 deletion migrations/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM flyway/flyway:12-alpine
FROM flyway/flyway:11-alpine

# Copy migrations
COPY ./sql /flyway/sql
Expand Down
Loading