{{/* Expand the name of the chart. */}} {{- define "yourls-nginx.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Create a default fully qualified app name. */}} {{- define "yourls-nginx.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 "yourls-nginx.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} {{- define "yourls-nginx.labels" -}} helm.sh/chart: {{ include "yourls-nginx.chart" . }} {{ include "yourls-nginx.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* Selector labels */}} {{- define "yourls-nginx.selectorLabels" -}} app.kubernetes.io/name: {{ include "yourls-nginx.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Secret name used for chart-managed credentials. */}} {{- define "yourls-nginx.secretName" -}} {{- printf "%s-secret" (include "yourls-nginx.fullname" .) }} {{- end }} {{/* Fetch a previously-generated value from the existing chart-managed Secret, if any. Used so that random values (cookiekey, auto-generated admin password) survive "helm upgrade" instead of rotating on every release, which would otherwise invalidate admin login cookies and previously-issued passwords. Usage: {{ include "yourls-nginx.existingSecretValue" (list . "cookiekey") }} Returns an empty string on first install (no Secret exists yet) or when running "helm template" without cluster access. */}} {{- define "yourls-nginx.existingSecretValue" -}} {{- $ctx := index . 0 -}} {{- $key := index . 1 -}} {{- $secret := lookup "v1" "Secret" $ctx.Release.Namespace (include "yourls-nginx.secretName" $ctx) -}} {{- if $secret -}} {{- $value := index $secret.data $key -}} {{- if $value -}} {{- $value | b64dec -}} {{- end -}} {{- end -}} {{- end }}