|
| 1 | +{{/* |
| 2 | +Expand the name of the chart. |
| 3 | +*/}} |
| 4 | +{{- define "cooked.name" -}} |
| 5 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 6 | +{{- end }} |
| 7 | + |
| 8 | +{{/* |
| 9 | +Create a default fully qualified app name. |
| 10 | +Truncated to 63 characters (DNS label limit). |
| 11 | +*/}} |
| 12 | +{{- define "cooked.fullname" -}} |
| 13 | +{{- if .Values.fullnameOverride }} |
| 14 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 15 | +{{- else }} |
| 16 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 17 | +{{- if contains $name .Release.Name }} |
| 18 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 19 | +{{- else }} |
| 20 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 21 | +{{- end }} |
| 22 | +{{- end }} |
| 23 | +{{- end }} |
| 24 | + |
| 25 | +{{/* |
| 26 | +Create chart name and version for the helm.sh/chart label. |
| 27 | +*/}} |
| 28 | +{{- define "cooked.chart" -}} |
| 29 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 30 | +{{- end }} |
| 31 | + |
| 32 | +{{/* |
| 33 | +Standard labels for all resources. |
| 34 | +*/}} |
| 35 | +{{- define "cooked.labels" -}} |
| 36 | +helm.sh/chart: {{ include "cooked.chart" . }} |
| 37 | +{{ include "cooked.selectorLabels" . }} |
| 38 | +{{- if .Chart.AppVersion }} |
| 39 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 40 | +{{- end }} |
| 41 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 42 | +{{- with .Values.commonLabels }} |
| 43 | +{{ toYaml . }} |
| 44 | +{{- end }} |
| 45 | +{{- end }} |
| 46 | + |
| 47 | +{{/* |
| 48 | +Selector labels (immutable — never include version here). |
| 49 | +*/}} |
| 50 | +{{- define "cooked.selectorLabels" -}} |
| 51 | +app.kubernetes.io/name: {{ include "cooked.name" . }} |
| 52 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 53 | +{{- end }} |
| 54 | + |
| 55 | +{{/* |
| 56 | +Common annotations for all resources. |
| 57 | +*/}} |
| 58 | +{{- define "cooked.annotations" -}} |
| 59 | +{{- with .Values.commonAnnotations }} |
| 60 | +{{- toYaml . }} |
| 61 | +{{- end }} |
| 62 | +{{- end }} |
| 63 | + |
| 64 | +{{/* |
| 65 | +Service account name. |
| 66 | +*/}} |
| 67 | +{{- define "cooked.serviceAccountName" -}} |
| 68 | +{{- if .Values.serviceAccount.create }} |
| 69 | +{{- default (include "cooked.fullname" .) .Values.serviceAccount.name }} |
| 70 | +{{- else }} |
| 71 | +{{- default "default" .Values.serviceAccount.name }} |
| 72 | +{{- end }} |
| 73 | +{{- end }} |
| 74 | + |
| 75 | +{{/* |
| 76 | +Container image string from registry/repository/tag/digest. |
| 77 | +When using appVersion as the default tag, prepends "v" to match GHCR tag format (v1.3.2). |
| 78 | +An explicit image.tag is used as-is. |
| 79 | +*/}} |
| 80 | +{{- define "cooked.image" -}} |
| 81 | +{{- if .Values.image.digest }} |
| 82 | +{{- printf "%s/%s@%s" .Values.image.registry .Values.image.repository .Values.image.digest }} |
| 83 | +{{- else if .Values.image.tag }} |
| 84 | +{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }} |
| 85 | +{{- else }} |
| 86 | +{{- printf "%s/%s:v%s" .Values.image.registry .Values.image.repository .Chart.AppVersion }} |
| 87 | +{{- end }} |
| 88 | +{{- end }} |
0 commit comments