2 # Copyright © 2019 Orange
3 # Modifications Copyright (C) 2022 Bell Canada
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
22 The function takes several arguments (inside a dictionary):
23 - .dot : environment (.)
24 - .labels : labels to add (dict)
26 {{- define "common.labels" -}}
27 {{- $dot := default . .dot -}}
28 app.kubernetes.io/name: {{ include "common.name" $dot }}
29 {{ if not .ignoreHelmChart }}
30 helm.sh/chart: {{ include "common.chart" $dot }}
32 app.kubernetes.io/instance: {{ include "common.release" $dot }}
33 app.kubernetes.io/managed-by: {{ $dot.Release.Service }}
35 {{- include "common.tplValue" (dict "value" .labels "context" $dot) }}
40 Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
41 The function takes several arguments (inside a dictionary):
42 - .dot : environment (.)
43 - .matchLabels: selectors/matchlLabels to add (dict)
45 {{- define "common.matchLabels" -}}
46 {{- $dot := default . .dot -}}
47 {{- $matchLabels := default (dict) .matchLabels -}}
48 {{- if not $matchLabels.nameNoMatch -}}
49 app.kubernetes.io/name: {{ include "common.name" $dot }}
51 app.kubernetes.io/instance: {{ include "common.release" $dot }}
52 {{- if $matchLabels }}
53 {{$_ := unset $matchLabels "nameNoMatch"}}
54 {{- include "common.tplValue" (dict "value" $matchLabels "context" $dot) }}
59 Generate "top" metadata for Deployment / StatefulSet / ...
60 The function takes several arguments (inside a dictionary):
61 - .dot : environment (.)
62 - .labels: labels to add (dict)
63 - .suffix: suffix to name
66 {{- define "common.resourceMetadata" -}}
67 {{- $dot := default . .dot -}}
68 {{- $suffix := default "" .suffix -}}
69 {{- $labels := default (dict) .labels -}}
70 {{- $annotations := default (dict) .annotations -}}
71 name: {{ include "common.fullname" (dict "suffix" $suffix "dot" $dot )}}
72 namespace: {{ include "common.namespace" $dot }}
73 labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot ) | nindent 2 }}
74 {{- if $annotations }}
75 annotations: {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}}
80 Generate selectors for Deployment / StatefulSet / ...
81 The function takes several arguments (inside a dictionary):
82 - .dot : environment (.)
83 - .matchLabels: labels to add (dict)
85 {{- define "common.selectors" -}}
86 {{- $dot := default . .dot -}}
87 {{- $matchLabels := default (dict) .matchLabels -}}
88 matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels "dot" $dot) | nindent 2 }}
92 Generate "template" metadata for Deployment / StatefulSet / ...
93 The function takes several arguments (inside a dictionary)
94 - .dot : environment (.)
95 - .labels: labels to add (dict)
97 {{- define "common.templateMetadata" -}}
98 {{- $dot := default . .dot -}}
99 {{- $labels := default (dict) .labels -}}
100 {{- if $dot.Values.podAnnotations }}
101 annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $dot) | nindent 2 }}
103 labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot) | nindent 2 }}
104 name: {{ include "common.name" $dot }}