|
| 1 | +{{/* |
| 2 | +Chart name and fullname |
| 3 | +*/}} |
| 4 | +{{- define "garage.name" -}} |
| 5 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 6 | +{{- end }} |
| 7 | + |
| 8 | +{{- define "garage.fullname" -}} |
| 9 | +{{- if .Values.fullnameOverride }} |
| 10 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 11 | +{{- else }} |
| 12 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 13 | +{{- if contains $name .Release.Name }} |
| 14 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 15 | +{{- else }} |
| 16 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 17 | +{{- end }} |
| 18 | +{{- end }} |
| 19 | +{{- end }} |
| 20 | + |
| 21 | +{{- define "garage.chart" -}} |
| 22 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 23 | +{{- end }} |
| 24 | + |
| 25 | +{{- define "garage.labels" -}} |
| 26 | +helm.sh/chart: {{ include "garage.chart" . }} |
| 27 | +{{ include "garage.selectorLabels" . }} |
| 28 | +{{- if .Chart.AppVersion }} |
| 29 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 30 | +{{- end }} |
| 31 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 32 | +{{- end }} |
| 33 | + |
| 34 | +{{- define "garage.selectorLabels" -}} |
| 35 | +app.kubernetes.io/name: {{ include "garage.name" . }} |
| 36 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 37 | +{{- end }} |
| 38 | + |
| 39 | +{{/* |
| 40 | +Name of the ServiceAccount to use. |
| 41 | +*/}} |
| 42 | +{{- define "garage.serviceAccountName" -}} |
| 43 | +{{- if .Values.serviceAccount.create }} |
| 44 | +{{- default (include "garage.fullname" .) .Values.serviceAccount.name }} |
| 45 | +{{- else }} |
| 46 | +{{- default "default" .Values.serviceAccount.name }} |
| 47 | +{{- end }} |
| 48 | +{{- end }} |
| 49 | + |
| 50 | +{{/* |
| 51 | +Stable per-release RPC secret (inter-node clustering auth; loopback-only on a |
| 52 | +single node). `lookup` is used so that on `helm upgrade` we keep the previously |
| 53 | +generated value instead of rotating it (which would orphan the existing |
| 54 | +single-node cluster layout). The admin_token, by contrast, is a required, |
| 55 | +operator-provided value (see admin.token) so it is known up front. |
| 56 | +*/}} |
| 57 | +{{- define "garage.rpcSecret" -}} |
| 58 | +{{- $existing := (lookup "v1" "Secret" .Release.Namespace (include "garage.fullname" .)) -}} |
| 59 | +{{- if $existing -}} |
| 60 | +{{- index $existing.data "rpc_secret" | b64dec -}} |
| 61 | +{{- else -}} |
| 62 | +{{- sha256sum (printf "%s-rpc-%s" .Release.Name (randAlphaNum 32)) -}} |
| 63 | +{{- end -}} |
| 64 | +{{- end }} |
0 commit comments