mirror of
https://gitlab.fabcity.hamburg/software/fab-city-os-core-chart.git
synced 2024-09-20 04:18:52 +02:00
247 lines
7.5 KiB
Smarty
247 lines
7.5 KiB
Smarty
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
{{- define "fcoscore.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Create a default fully qualified app name.
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
If release name contains chart name it will be used as a full name.
|
|
*/}}
|
|
{{- define "fcoscore.fullname" -}}
|
|
{{- if .Values.fullnameOverride }}
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
|
{{- else }}
|
|
{{- $name := default .Chart.Name .Values.nameOverride }}
|
|
{{- if contains $name .Release.Name }}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
|
{{- else }}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Create chart name and version as used by the chart label.
|
|
*/}}
|
|
{{- define "fcoscore.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "fcoscore.labels" -}}
|
|
helm.sh/chart: {{ include "fcoscore.chart" . }}
|
|
{{ include "fcoscore.selectorLabels" . }}
|
|
{{- if .Chart.AppVersion }}
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
{{- end }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Selector labels
|
|
*/}}
|
|
{{- define "fcoscore.selectorLabels" -}}
|
|
app.kubernetes.io/name: {{ include "fcoscore.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Create the name of the service account to use
|
|
*/}}
|
|
{{- define "fcoscore.serviceAccountName" -}}
|
|
{{- if .Values.serviceAccount.create }}
|
|
{{- default (include "fcoscore.fullname" .) .Values.serviceAccount.name }}
|
|
{{- else }}
|
|
{{- default "default" .Values.serviceAccount.name }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Get the user defined LoadBalancerIP for this release
|
|
Note, returns 127.0.0.1 if using ClusterIP.
|
|
*/}}
|
|
{{- define "fcoscore.serviceIP" -}}
|
|
{{- if eq .Values.service.type "ClusterIP" -}}
|
|
127.0.0.1
|
|
{{- else -}}
|
|
{{- .Values.service.loadBalancerIP | default "" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Gets the host to be used for this application.
|
|
If not using ClusterIP, or if a host or LoadBalancerIP is not defined, the value will be empty
|
|
*/}}
|
|
{{- define "fcoscore.host" -}}
|
|
{{- if .Values.ingress.enabled }}
|
|
{{- $host := .Values.ingress.hostname | default "" -}}
|
|
{{- default (include "fcoscore.serviceIP" .) $host -}}
|
|
{{- else -}}
|
|
{{- $host := .Values.host | default "" -}}
|
|
{{- default (include "fcoscore.serviceIP" .) $host -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return true if a secret object for FabCityOS should be created
|
|
*/}}
|
|
{{- define "fcoscore.createSecret" -}}
|
|
{{- if or (and .Values.smtp.enabled .Values.smtp.password (not .Values.smtp.existingSecret)) }}
|
|
{{- true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the FabCityOS secret name
|
|
*/}}
|
|
{{- define "fcoscore.secretName" -}}
|
|
{{- default (include "common.names.fullname" .) -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql hostname
|
|
*/}}
|
|
{{- define "fcoscore.database.host" -}}
|
|
{{- ternary (include "fcoscore.postgresql.fullname" .) .Values.externalDatabase.host .Values.postgresql.enabled | quote -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql port
|
|
*/}}
|
|
{{- define "fcoscore.database.port" -}}
|
|
{{- ternary "5432" .Values.externalDatabase.port .Values.postgresql.enabled | quote -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql database name
|
|
*/}}
|
|
{{- define "fcoscore.database.name" -}}
|
|
{{- if .Values.postgresql.enabled }}
|
|
{{- if .Values.global.postgresql }}
|
|
{{- if .Values.global.postgresql.auth }}
|
|
{{- coalesce .Values.global.postgresql.auth.database .Values.postgresql.auth.database | quote -}}
|
|
{{- else -}}
|
|
{{- .Values.postgresql.auth.database | quote -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- .Values.postgresql.auth.database | quote -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- .Values.externalDatabase.database | quote -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql user
|
|
*/}}
|
|
{{- define "fcoscore.database.user" -}}
|
|
{{- if .Values.postgresql.enabled }}
|
|
{{- if .Values.global.postgresql }}
|
|
{{- if .Values.global.postgresql.auth }}
|
|
{{- coalesce .Values.global.postgresql.auth.username .Values.postgresql.auth.username | quote -}}
|
|
{{- else -}}
|
|
{{- .Values.postgresql.auth.username | quote -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- .Values.postgresql.auth.username | quote -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- .Values.externalDatabase.user | quote -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql secret name
|
|
*/}}
|
|
{{- define "fcoscore.database.secretName" -}}
|
|
{{- if .Values.postgresql.enabled }}
|
|
{{- if .Values.global.postgresql }}
|
|
{{- if .Values.global.postgresql.auth }}
|
|
{{- if .Values.global.postgresql.auth.existingSecret }}
|
|
{{- tpl .Values.global.postgresql.auth.existingSecret $ -}}
|
|
{{- else -}}
|
|
{{- default (include "fcoscore.postgresql.fullname" .) (tpl .Values.postgresql.auth.existingSecret $) -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- default (include "fcoscore.postgresql.fullname" .) (tpl .Values.postgresql.auth.existingSecret $) -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- default (include "fcoscore.postgresql.fullname" .) (tpl .Values.postgresql.auth.existingSecret $) -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- default (printf "%s-database" .Release.Name) (tpl .Values.externalDatabase.existingSecret $) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql password secret key
|
|
*/}}
|
|
{{- define "fcoscore.database.secretPasswordKey" -}}
|
|
{{- if .Values.postgresql.enabled -}}
|
|
{{- print "password" -}}
|
|
{{- else -}}
|
|
{{- if .Values.externalDatabase.existingSecret -}}
|
|
{{- default "password" .Values.externalDatabase.existingSecretPasswordKey }}
|
|
{{- else -}}
|
|
{{- print "password" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the Postgresql postgres password secret key
|
|
*/}}
|
|
{{- define "fcoscore.database.secretPostgresPasswordKey" -}}
|
|
{{- if .Values.postgresql.enabled -}}
|
|
{{- print "postgres-password" -}}
|
|
{{- else -}}
|
|
{{- if .Values.externalDatabase.existingSecret -}}
|
|
{{- default "postgres-password" .Values.externalDatabase.existingSecretPostgresPasswordKey }}
|
|
{{- else -}}
|
|
{{- print "postgres-password" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default fully qualified app name
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
*/}}
|
|
{{- define "fcoscore.postgresql.fullname" -}}
|
|
{{- include "common.names.dependency.fullname" (dict "chartName" "postgresql" "chartValues" .Values.postgresql "context" $) -}}
|
|
{{- end -}}
|
|
|
|
{{- define "fcoscore.meilisearch.host" -}}
|
|
{{- include "common.names.dependency.fullname" (dict "chartName" "meilisearch" "chartValues" .Values.meilisearch "context" $) -}}
|
|
{{- end }}
|
|
|
|
{{- define "fcoscore.meilisearch.port" -}}
|
|
{{- .Values.meilisearch.service.port -}}
|
|
{{- end -}}
|
|
|
|
{{- define "fcoscore.meilisearch.url" -}}
|
|
{{- printf "http://%s:%s" (include "fcoscore.meilisearch.host" . ) (include "fcoscore.meilisearch.port" . ) -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the FabCityOS SMTP secret name
|
|
*/}}
|
|
{{- define "smtp.secretName" -}}
|
|
{{- default (printf "%s" (include "common.names.fullname" .)) (tpl .Values.smtp.existingSecret $) -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return true if FabCityOS SMTP uses password authentication
|
|
*/}}
|
|
{{- define "smtp.password.enabled" -}}
|
|
{{- if and .Values.smtp.enabled (or .Values.smtp.password .Values.smtp.existingSecret) }}
|
|
{{- true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|