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 app: {{ include "common.name" $dot }}
30 {{- if $dot.Chart.AppVersion }}
31 version: "{{ $dot.Chart.AppVersion | replace "+" "_" }}"
33 version: "{{ $dot.Chart.Version | replace "+" "_" }}"
35 {{ if not .ignoreHelmChart }}
36 helm.sh/chart: {{ include "common.chart" $dot }}
38 app.kubernetes.io/instance: {{ include "common.release" $dot }}
39 app.kubernetes.io/managed-by: {{ $dot.Release.Service }}
41 {{- include "common.tplValue" (dict "value" .labels "context" $dot) }}
46 Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
47 The function takes several arguments (inside a dictionary):
48 - .dot : environment (.)
49 - .matchLabels: selectors/matchlLabels to add (dict)
51 {{- define "common.matchLabels" -}}
52 {{- $dot := default . .dot -}}
53 {{- $matchLabels := default (dict) .matchLabels -}}
54 {{- if not $matchLabels.nameNoMatch -}}
55 app.kubernetes.io/name: {{ include "common.name" $dot }}
57 app.kubernetes.io/instance: {{ include "common.release" $dot }}
58 {{- if $matchLabels }}
59 {{$_ := unset $matchLabels "nameNoMatch"}}
60 {{- include "common.tplValue" (dict "value" $matchLabels "context" $dot) }}
65 Generate "top" metadata for Deployment / StatefulSet / ...
66 The function takes several arguments (inside a dictionary):
67 - .dot : environment (.)
68 - .labels: labels to add (dict)
69 - .suffix: suffix to name
72 {{- define "common.resourceMetadata" -}}
73 {{- $dot := default . .dot -}}
74 {{- $suffix := default "" .suffix -}}
75 {{- $labels := default (dict) .labels -}}
76 {{- $annotations := default (dict) .annotations -}}
77 name: {{ include "common.fullname" (dict "suffix" $suffix "dot" $dot )}}
78 namespace: {{ include "common.namespace" $dot }}
79 labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot ) | nindent 2 }}
80 {{- if $annotations }}
81 annotations: {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}}
86 Generate selectors for Deployment / StatefulSet / ...
87 The function takes several arguments (inside a dictionary):
88 - .dot : environment (.)
89 - .matchLabels: labels to add (dict)
91 {{- define "common.selectors" -}}
92 {{- $dot := default . .dot -}}
93 {{- $matchLabels := default (dict) .matchLabels -}}
94 matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels "dot" $dot) | nindent 2 }}
98 Generate "template" metadata for Deployment / StatefulSet / ...
99 The function takes several arguments (inside a dictionary)
100 - .dot : environment (.)
101 - .labels: labels to add (dict)
103 {{- define "common.templateMetadata" -}}
104 {{- $dot := default . .dot -}}
105 {{- $labels := default (dict) .labels -}}
106 {{- if $dot.Values.podAnnotations }}
107 annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $dot) | nindent 2 }}
109 labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot) | nindent 2 }}
110 name: {{ include "common.name" $dot }}