|
| 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 | +{{- $baseName := .Values.serviceAccount.name | default (printf "sa-%s" (include "garage.fullname" .)) -}} |
| 45 | +{{- $baseName | trunc 63 | trimSuffix "-" }} |
| 46 | +{{- else }} |
| 47 | +{{- default "default" .Values.serviceAccount.name }} |
| 48 | +{{- end }} |
| 49 | +{{- end }} |
| 50 | + |
| 51 | +{{/* |
| 52 | +Names for the ingress / HTTPRoute objects (prefixed for readability, overridable |
| 53 | +via .Values.<kind>.name). These name the routing object only — the backend still |
| 54 | +targets the Service (garage.fullname). |
| 55 | +*/}} |
| 56 | +{{- define "garage.ingressName" -}} |
| 57 | +{{- $baseName := .Values.ingress.name | default (printf "ingress-%s" (include "garage.fullname" .)) -}} |
| 58 | +{{- $baseName | trunc 63 | trimSuffix "-" }} |
| 59 | +{{- end }} |
| 60 | + |
| 61 | +{{- define "garage.httpRouteName" -}} |
| 62 | +{{- $baseName := .Values.httpRoute.name | default (printf "httproute-%s" (include "garage.fullname" .)) -}} |
| 63 | +{{- $baseName | trunc 63 | trimSuffix "-" }} |
| 64 | +{{- end }} |
| 65 | + |
| 66 | +{{/* |
| 67 | +Auto-generated RPC secret (inter-node clustering auth; loopback-only on a single |
| 68 | +node, so it is never consumed externally). `lookup` reuses the previously stored |
| 69 | +value on `helm upgrade` to avoid a needless Secret diff — this is churn |
| 70 | +avoidance, not a correctness requirement: the node's identity and cluster layout |
| 71 | +live in the metadata volume, independent of this secret, so regenerating it does |
| 72 | +not lose data or orphan the layout. The admin_token, by contrast, is a required, |
| 73 | +operator-provided value (see admin.token) so it is known up front. |
| 74 | +*/}} |
| 75 | +{{- define "garage.rpcSecret" -}} |
| 76 | +{{- $existing := (lookup "v1" "Secret" .Release.Namespace (include "garage.fullname" .)) -}} |
| 77 | +{{- if $existing -}} |
| 78 | +{{- index $existing.data "rpc_secret" | b64dec -}} |
| 79 | +{{- else -}} |
| 80 | +{{- sha256sum (printf "%s-rpc-%s" .Release.Name (randAlphaNum 32)) -}} |
| 81 | +{{- end -}} |
| 82 | +{{- end }} |
0 commit comments