{{/* 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 "prestashop.mariadb.fullname" -}} {{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Get the user defined LoadBalancerIP for this release. Note, returns 127.0.0.1 if using ClusterIP. */}} {{- define "prestashop.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. When using Ingress, it will be set to the Ingress hostname. */}} {{- define "prestashop.host" -}} {{- if .Values.ingress.enabled }} {{- $host := .Values.ingress.hostname | default "" -}} {{- default (include "prestashop.serviceIP" .) $host -}} {{- else -}} {{- $host := index .Values (printf "%sHost" .Chart.Name) | default "" -}} {{- default (include "prestashop.serviceIP" .) $host -}} {{- end -}} {{- end -}} {{/* Return the proper certificate image name */}} {{- define "certificates.image" -}} {{- include "common.images.image" ( dict "imageRoot" .Values.certificates.image "global" .Values.global ) -}} {{- end -}} {{/* Return the proper PrestaShop image name */}} {{- define "prestashop.image" -}} {{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) -}} {{- end -}} {{/* Return the proper image name (for the metrics image) */}} {{- define "prestashop.metrics.image" -}} {{- include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) -}} {{- end -}} {{/* Return the proper image name (for the init container volume-permissions image) */}} {{- define "prestashop.volumePermissions.image" -}} {{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}} {{- end -}} {{/* Return the proper Docker Image Registry Secret Names */}} {{- define "prestashop.imagePullSecrets" -}} {{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.metrics.image .Values.volumePermissions.image .Values.certificates.image) "global" .Values.global) -}} {{- end -}} {{/* Return the proper Storage Class */}} {{- define "prestashop.storageClass" -}} {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) -}} {{- end -}} {{/* PrestaShop credential secret name */}} {{- define "prestashop.secretName" -}} {{- coalesce .Values.existingSecret (include "common.names.fullname" .) -}} {{- end -}} {{/* Return the MariaDB Hostname */}} {{- define "prestashop.databaseHost" -}} {{- if .Values.mariadb.enabled }} {{- if eq .Values.mariadb.architecture "replication" }} {{- printf "%s-%s" (include "prestashop.mariadb.fullname" .) "primary" | trunc 63 | trimSuffix "-" -}} {{- else -}} {{- printf "%s" (include "prestashop.mariadb.fullname" .) -}} {{- end -}} {{- else -}} {{- printf "%s" .Values.externalDatabase.host -}} {{- end -}} {{- end -}} {{/* Return the MariaDB Port */}} {{- define "prestashop.databasePort" -}} {{- if .Values.mariadb.enabled }} {{- printf "3306" -}} {{- else -}} {{- printf "%d" (.Values.externalDatabase.port | int ) -}} {{- end -}} {{- end -}} {{/* Return the MariaDB Database Name */}} {{- define "prestashop.databaseName" -}} {{- if .Values.mariadb.enabled }} {{- printf "%s" .Values.mariadb.auth.database -}} {{- else -}} {{- printf "%s" .Values.externalDatabase.database -}} {{- end -}} {{- end -}} {{/* Return the MariaDB User */}} {{- define "prestashop.databaseUser" -}} {{- if .Values.mariadb.enabled }} {{- printf "%s" .Values.mariadb.auth.username -}} {{- else -}} {{- printf "%s" .Values.externalDatabase.user -}} {{- end -}} {{- end -}} {{/* Return the MariaDB Secret Name */}} {{- define "prestashop.databaseSecretName" -}} {{- if .Values.mariadb.enabled }} {{- printf "%s" (include "prestashop.mariadb.fullname" .) -}} {{- else if .Values.externalDatabase.existingSecret -}} {{- printf "%s" .Values.externalDatabase.existingSecret -}} {{- else -}} {{- printf "%s-%s" (include "common.names.fullname" .) "externaldb" -}} {{- end -}} {{- end -}} {{/* Return the database password key */}} {{- define "prestashop.databasePasswordKey" -}} {{- if .Values.mariadb.enabled -}} mariadb-password {{- else -}} db-password {{- end -}} {{- end -}}