2 # Copyright © 2019 Orange
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
21 The function takes several arguments (inside a dictionary):
22 - .dot : environment (.)
23 - .labels : labels to add (dict)
25 {{- define "common.labels" -}}
26 {{- $dot := default . .dot -}}
27 app.kubernetes.io/name: {{ include "common.name" $dot }}
28 helm.sh/chart: {{ include "common.chart" $dot }}
29 app.kubernetes.io/instance: {{ include "common.release" $dot }}
30 app.kubernetes.io/managed-by: {{ $dot.Release.Service }}
32 {{- include "common.tplValue" (dict "value" .labels "context" $dot) }}
37 Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
38 The function takes several arguments (inside a dictionary):
39 - .dot : environment (.)
40 - .matchLabels: selectors/matchlLabels to add (dict)
42 {{- define "common.matchLabels" -}}
43 {{- $dot := default . .dot -}}
44 {{- $matchLabels := default (dict) .matchLabels -}}
45 {{- if not $matchLabels.nameNoMatch -}}
46 app.kubernetes.io/name: {{ include "common.name" $dot }}
48 app.kubernetes.io/instance: {{ include "common.release" $dot }}
49 {{- if $matchLabels }}
50 {{$_ := unset $matchLabels "nameNoMatch"}}
51 {{- include "common.tplValue" (dict "value" $matchLabels "context" $dot) }}
56 Generate "top" metadata for Deployment / StatefulSet / ...
57 The function takes several arguments (inside a dictionary):
58 - .dot : environment (.)
59 - .labels: labels to add (dict)
60 - .suffix: suffix to name
63 {{- define "common.resourceMetadata" -}}
64 {{- $dot := default . .dot -}}
65 {{- $suffix := default "" .suffix -}}
66 {{- $labels := default (dict) .labels -}}
67 {{- $annotations := default (dict) .annotations -}}
68 name: {{ include "common.fullname" (dict "suffix" $suffix "dot" $dot )}}
69 namespace: {{ include "common.namespace" $dot }}
70 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot ) | nindent 2 }}
71 {{- if $annotations }}
72 annotations: {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}}
77 Generate selectors for Deployment / StatefulSet / ...
78 The function takes several arguments (inside a dictionary):
79 - .dot : environment (.)
80 - .matchLabels: labels to add (dict)
82 {{- define "common.selectors" -}}
83 {{- $dot := default . .dot -}}
84 {{- $matchLabels := default (dict) .matchLabels -}}
85 matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels "dot" $dot) | nindent 2 }}
89 Generate "template" metadata for Deployment / StatefulSet / ...
90 The function takes several arguments (inside a dictionary)
91 - .dot : environment (.)
92 - .labels: labels to add (dict)
94 {{- define "common.templateMetadata" -}}
95 {{- $dot := default . .dot -}}
96 {{- $labels := default (dict) .labels -}}
97 {{- if $dot.Values.podAnnotations }}
98 annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $dot) | nindent 2 }}
100 labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot) | nindent 2 }}
101 name: {{ include "common.name" $dot }}