Skip to content

Commit

Permalink
Merge pull request #112 from bci-oss/feature/configurable-postgres-va…
Browse files Browse the repository at this point in the history
…riables

Postgres variable configurable
  • Loading branch information
tunacicek authored Feb 19, 2024
2 parents 3e0a77f + 63904ba commit 01cde71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/discoveryfinder/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ home: https://eclipse-tractusx.github.io/
sources:
- https://github.com/eclipse-tractusx/sldt-discovery-finder
type: application
version: 0.2.1
version: 0.2.2
appVersion: 0.2.7

dependencies:
Expand Down
19 changes: 18 additions & 1 deletion charts/discoveryfinder/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,21 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- define "df.selectorLabels" -}}
app.kubernetes.io/name: {{ include "df.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- end }}

{{/*
Determine database hostname
*/}}

{{- define "df.postgres.primary.fullname" -}}
{{- if .Values.postgresql.fullnameOverride -}}
{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
6 changes: 3 additions & 3 deletions charts/discoveryfinder/templates/postgres-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data:
{{- $password:= ( .Values.postgresql.auth.password | b64enc) | default ( index $secret.data "password" ) | quote }}
password: {{ $password }}
SPRING_DATASOURCE_PASSWORD: {{ $password }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s-postgresql:%v/%s" .Release.Name .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database | b64enc }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s:%v/%s" (include "df.postgres.primary.fullname" .) .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database | b64enc }}
SPRING_DATASOURCE_USERNAME: {{ .Values.postgresql.auth.username | b64enc }}
# 2. Check if default postgresql secret (Release.Name-postgresql) exists
{{ else if $defaultSecret -}}
Expand All @@ -46,7 +46,7 @@ data:
{{- $password:= ( .Values.postgresql.auth.password | b64enc) | default ( index $defaultSecret.data "password" ) | quote }}
password: {{ $password }}
SPRING_DATASOURCE_PASSWORD: {{ $password }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s-postgresql:%v/%s" .Release.Name .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database | b64enc }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s:%v/%s" (include "df.postgres.primary.fullname" .) .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database | b64enc }}
SPRING_DATASOURCE_USERNAME: {{ .Values.postgresql.auth.username | b64enc }}
{{ else -}}
# 3. If no secret exists, use provided value from values file or generate a random one if secret not exists.
Expand All @@ -55,7 +55,7 @@ stringData:
postgres-password: {{ $password }}
password: {{ $password }}
SPRING_DATASOURCE_PASSWORD: {{ $password }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s-postgresql:%v/%s" .Release.Name .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database }}
SPRING_DATASOURCE_URL: {{ printf "jdbc:postgresql://%s:%v/%s" (include "df.postgres.primary.fullname" .) .Values.postgresql.service.ports.postgresql .Values.postgresql.auth.database }}
SPRING_DATASOURCE_USERNAME: {{ .Values.postgresql.auth.username }}
{{ end }}
{{- end -}}

0 comments on commit 01cde71

Please sign in to comment.