Skip to content

Commit

Permalink
Fix external postgres database handling (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
gionn authored Oct 2, 2024
1 parent 6e09c87 commit 81b47aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions helm/alfresco-content-services/templates/_helpers-database.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Usage: include "alfresco-content-services.database.repo" $
{{- with .Values }}
{{- if and (not .database.url) (not .postgresql.enabled) }}
{{- fail "You must either set database.url or postgresql.enabled" }}
{{- end }}
{{- if .database.url }}
{{- .database.url }}
{{- else }}
{{- $pg_port := .postgresql.primary.service.ports.postgresql | toString }}
{{- $pg_url := printf "postgresql://%s-%s:%s/%s" $.Release.Name .postgresql.nameOverride $pg_port .postgresql.auth.database }}
{{- .database.url | default $pg_url }}
{{- printf "postgresql://%s-%s:%s/%s" $.Release.Name .postgresql.nameOverride $pg_port .postgresql.auth.database }}
{{- end }}
{{- end }}
{{- end -}}
Expand All @@ -26,10 +28,12 @@ Usage: include "alfresco-content-services.database.sync" $
{{- with .Values }}
{{- if and (not .database.sync.url) (not (index . "postgresql-sync" "enabled")) }}
{{- fail "You must either set database.sync.url or postgresql-sync.enabled values" }}
{{- end }}
{{- if .database.sync.url }}
{{- .database.sync.url }}
{{- else }}
{{- $pg_port := index . "postgresql-sync" "primary" "service" "ports" "postgresql" | toString }}
{{- $pg_url := printf "postgresql://%s-%s:%s/%s" $.Release.Name (index . "postgresql-sync" "nameOverride") $pg_port (index . "postgresql-sync" "auth" "database") }}
{{- .database.sync.url | default $pg_url }}
{{- printf "postgresql://%s-%s:%s/%s" $.Release.Name (index . "postgresql-sync" "nameOverride") $pg_port (index . "postgresql-sync" "auth" "database") }}
{{- end }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,13 @@ tests:
- failedTemplate:
errorMEssage: >-
Alfresco Intelligence service has been enabled but Transformation service is not available
- it: should permit disabling embedded postgresql
values: *testvalues
set:
postgresql.enabled: false
database.url: jdbc:postgresql://alfresco:QA6fMXtdr%3EK%2F8aDFft,MJ%40p%[email protected]:5432/alfresco
asserts:
- equal:
path: data.DATABASE_URL
value: jdbc:postgresql://alfresco:QA6fMXtdr%3EK%2F8aDFft,MJ%40p%[email protected]:5432/alfresco

0 comments on commit 81b47aa

Please sign in to comment.