diff --git a/charts/discoveryfinder/Chart.yaml b/charts/discoveryfinder/Chart.yaml index c1553de..d9c1a3c 100644 --- a/charts/discoveryfinder/Chart.yaml +++ b/charts/discoveryfinder/Chart.yaml @@ -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: diff --git a/charts/discoveryfinder/templates/_helpers.tpl b/charts/discoveryfinder/templates/_helpers.tpl index eadc3da..6142f3c 100644 --- a/charts/discoveryfinder/templates/_helpers.tpl +++ b/charts/discoveryfinder/templates/_helpers.tpl @@ -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 }} \ No newline at end of file +{{- 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 -}} diff --git a/charts/discoveryfinder/templates/postgres-init.yaml b/charts/discoveryfinder/templates/postgres-init.yaml index fbb1e8f..f46ca3a 100644 --- a/charts/discoveryfinder/templates/postgres-init.yaml +++ b/charts/discoveryfinder/templates/postgres-init.yaml @@ -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 -}} @@ -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. @@ -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 -}} \ No newline at end of file