|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | + |
| 3 | +{{/* |
| 4 | +Expand the name of the chart. |
| 5 | +*/}} |
| 6 | +{{- define "otel.name" -}} |
| 7 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 8 | +{{- end }} |
| 9 | + |
| 10 | +{{/* |
| 11 | +Create a default fully qualified app name. |
| 12 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 13 | +If release name contains chart name it will be used as a full name. |
| 14 | +*/}} |
| 15 | +{{- define "otel.fullname" -}} |
| 16 | +{{- if .Values.fullnameOverride }} |
| 17 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 18 | +{{- else }} |
| 19 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 20 | +{{- if contains $name .Release.Name }} |
| 21 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 22 | +{{- else }} |
| 23 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 24 | +{{- end }} |
| 25 | +{{- end }} |
| 26 | +{{- end }} |
| 27 | + |
| 28 | +{{/* |
| 29 | +Create chart name and version as used by the chart label. |
| 30 | +*/}} |
| 31 | +{{- define "otel.chart" -}} |
| 32 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 33 | +{{- end }} |
| 34 | + |
| 35 | +{{/* |
| 36 | +Common labels |
| 37 | +*/}} |
| 38 | +{{- define "otel.labels" -}} |
| 39 | +helm.sh/chart: {{ include "otel.chart" . }} |
| 40 | +{{ include "otel.selectorLabels" . }} |
| 41 | +{{- if .Chart.AppVersion }} |
| 42 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 43 | +{{- end }} |
| 44 | +ctrlplane.com/app-name: {{ include "otel.chart" . }} |
| 45 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 46 | +{{- end }} |
| 47 | + |
| 48 | +{{/* |
| 49 | +Selector labels |
| 50 | +*/}} |
| 51 | +{{- define "otel.selectorLabels" -}} |
| 52 | +app.kubernetes.io/name: {{ include "otel.name" . }} |
| 53 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 54 | +{{- end }} |
| 55 | + |
| 56 | +{{/* |
| 57 | +Create the name of the service account to use |
| 58 | +*/}} |
| 59 | +{{- define "otel.serviceAccountName" -}} |
| 60 | +{{- if .Values.serviceAccount.create }} |
| 61 | +{{- default (include "otel.fullname" .) .Values.serviceAccount.name }} |
| 62 | +{{- else }} |
| 63 | +{{- default "default" .Values.serviceAccount.name }} |
| 64 | +{{- end }} |
| 65 | +{{- end }} |
| 66 | + |
| 67 | +{{/* |
| 68 | +Returns the extraEnv keys and values to inject into containers. |
| 69 | +
|
| 70 | +Global values will override any chart-specific values. |
| 71 | +*/}} |
| 72 | +{{- define "otel.extraEnv" -}} |
| 73 | +{{- $allExtraEnv := merge (default (dict) .local.extraEnv) .global.extraEnv -}} |
| 74 | +{{- range $key, $value := $allExtraEnv }} |
| 75 | +- name: {{ $key }} |
| 76 | + value: {{ $value | quote }} |
| 77 | +{{- end -}} |
| 78 | +{{- end -}} |
| 79 | + |
| 80 | +{{/* |
| 81 | +Returns a list of _common_ labels to be shared across all |
| 82 | +app deployments and other shared objects. |
| 83 | +*/}} |
| 84 | +{{- define "otel.commonLabels" -}} |
| 85 | +{{- $commonLabels := default (dict) .Values.common.labels -}} |
| 86 | +{{- if $commonLabels }} |
| 87 | +{{- range $key, $value := $commonLabels }} |
| 88 | +{{ $key }}: {{ $value | quote }} |
| 89 | +{{- end }} |
| 90 | +{{- end -}} |
| 91 | +{{- end -}} |
| 92 | + |
| 93 | +{{/* |
| 94 | +Returns a list of _pod_ labels to be shared across all |
| 95 | +app deployments. |
| 96 | +*/}} |
| 97 | +{{- define "otel.podLabels" -}} |
| 98 | +{{- range $key, $value := .Values.pod.labels }} |
| 99 | +{{ $key }}: {{ $value | quote }} |
| 100 | +{{- end }} |
| 101 | +{{- end -}} |
| 102 | + |
0 commit comments