github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/kblib/templates/_metadata.tpl (about) 1 {{/* 2 Define the cluster name. 3 We truncate at 15 chars because KubeBlocks will concatenate the names of other resources with cluster name 4 */}} 5 {{- define "kblib.clusterName" }} 6 {{- $name := .Release.Name }} 7 {{- if not (regexMatch "^[a-z]([-a-z0-9]*[a-z0-9])?$" $name) }} 8 {{ fail (printf "Release name %q is invalid. It must match the regex %q." $name "^[a-z]([-a-z0-9]*[a-z0-9])?$") }} 9 {{- end }} 10 {{- if gt (len $name) 15 }} 11 {{ fail (printf "Release name %q is invalid, must be no more than 15 characters" $name) }} 12 {{- end }} 13 {{- $name }} 14 {{- end }} 15 16 {{/* 17 Create chart name and version as used by the chart label. 18 */}} 19 {{- define "kblib.chart" -}} 20 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 21 {{- end }} 22 23 {{/* 24 Define cluster labels 25 */}} 26 {{- define "kblib.clusterLabels" -}} 27 helm.sh/chart: {{ include "kblib.chart" . }} 28 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 29 app.kubernetes.io/instance: {{ include "kblib.clusterName" . }} 30 {{- end }}