Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mongodb / common / templates / _labels.tpl
1 {{/*
2 Copyright VMware, Inc.
3 SPDX-License-Identifier: APACHE-2.0
4 */}}
5
6 {{/* vim: set filetype=mustache: */}}
7
8 {{/*
9 Kubernetes standard labels
10 {{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}}
11 */}}
12 {{- define "common.labels.standard" -}}
13 {{- if and (hasKey . "customLabels") (hasKey . "context") -}}
14 {{- $default := dict "app.kubernetes.io/name" (include "common.names.name" .context) "helm.sh/chart" (include "common.names.chart" .context) "app.kubernetes.io/instance" .context.Release.Name "app.kubernetes.io/managed-by" .context.Release.Service -}}
15 {{- with .context.Chart.AppVersion -}}
16 {{- $_ := set $default "app.kubernetes.io/version" . -}}
17 {{- end -}}
18 {{ template "common.tplvalues.merge" (dict "values" (list .customLabels $default) "context" .context) }}
19 {{- else -}}
20 app.kubernetes.io/name: {{ include "common.names.name" . }}
21 helm.sh/chart: {{ include "common.names.chart" . }}
22 app.kubernetes.io/instance: {{ .Release.Name }}
23 app.kubernetes.io/managed-by: {{ .Release.Service }}
24 {{- with .Chart.AppVersion }}
25 app.kubernetes.io/version: {{ . | quote }}
26 {{- end -}}
27 {{- end -}}
28 {{- end -}}
29
30 {{/*
31 Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector
32 {{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}}
33
34 We don't want to loop over custom labels appending them to the selector
35 since it's very likely that it will break deployments, services, etc.
36 However, it's important to overwrite the standard labels if the user
37 overwrote them on metadata.labels fields.
38 */}}
39 {{- define "common.labels.matchLabels" -}}
40 {{- if and (hasKey . "customLabels") (hasKey . "context") -}}
41 {{ merge (pick (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) "app.kubernetes.io/name" "app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include "common.names.name" .context) "app.kubernetes.io/instance" .context.Release.Name ) | toYaml }}
42 {{- else -}}
43 app.kubernetes.io/name: {{ include "common.names.name" . }}
44 app.kubernetes.io/instance: {{ .Release.Name }}
45 {{- end -}}
46 {{- end -}}