-
Notifications
You must be signed in to change notification settings - Fork 566
Expand file tree
/
Copy path_helpers.tpl
More file actions
207 lines (184 loc) · 5.88 KB
/
_helpers.tpl
File metadata and controls
207 lines (184 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define ".Chart.Name .name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create service name
*/}}
{{- define ".servicename" -}}
{{- if .Values.service.name -}}
{{- .Values.service.name | trunc 63 | trimSuffix "-" -}}
{{- else if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 55 | trimSuffix "-" -}}-service
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 55 | trimSuffix "-" -}}-service
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 55 | trimSuffix "-" -}}-service
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create preview service name
*/}}
{{- define ".previewservicename" -}}
{{- if .Values.service.name -}}
{{- .Values.service.name | trunc 55 | trimSuffix "-" -}}-preview
{{- else if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 47 | trimSuffix "-" -}}-preview-service
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 47 | trimSuffix "-" -}}-preview-service
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 47 | trimSuffix "-" -}}-preview-service
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define ".Chart.Name .fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define ".Chart.Name .chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define ".Chart.Name .color" -}}
{{- $active0 := (index .Values.server.deployment 0).enabled -}}
{{/*
{{- $active1 := (index .Values.server.deployment 1).enabled -}}
*/}}
{{- $active1 := include "safeenabledcheck" . -}}
{{- $active := and $active0 $active1 -}}
{{- $active -}}
{{- end -}}
{{- define "safeenabledcheck" -}}
{{- if (eq (len .Values.server.deployment) 2) -}}
{{- if (index .Values.server.deployment 1).enabled -}}
{{- $active := true -}}
{{- $active -}}
{{- else -}}
{{- $active := false -}}
{{- $active -}}
{{- end -}}
{{- else -}}
{{- $active := false -}}
{{- $active -}}
{{- end -}}
{{- end -}}
{{- define "isCMVolumeExists" -}}
{{- $isCMVolumeExists := false -}}
{{- if .Values.ConfigMaps.enabled }}
{{- range .Values.ConfigMaps.maps }}
{{- if eq .type "volume"}}
{{- $isCMVolumeExists = true}}
{{- end }}
{{- end }}
{{- end }}
{{- $isCMVolumeExists -}}
{{- end -}}
{{- define "isSecretVolumeExists" -}}
{{- $isSecretVolumeExists := false -}}
{{- if .Values.ConfigSecrets.enabled }}
{{- range .Values.ConfigSecrets.secrets }}
{{- if eq .type "volume"}}
{{- $isSecretVolumeExists = true}}
{{- end }}
{{- end }}
{{- end }}
{{- $isSecretVolumeExists -}}
{{- end -}}
{{- define "serviceMonitorEnabled" -}}
{{- $SMenabled := false -}}
{{- range .Values.ContainerPort }}
{{- if .servicemonitor }}
{{- if and .servicemonitor.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- end }}
{{- end }}
{{- $SMenabled -}}
{{- end -}}
{{- define "VerticalPodAutoScalingEnabled" -}}
{{- $SMenabled := false -}}
{{- if and .Values.verticalPodScaling.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- $SMenabled -}}
{{- end -}}
{{/* Create the name of the service account to use */}}
{{- define "serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include ".Chart.Name .fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/* Check for app/release labels in customPodLabels and replace accordingly */}}
{{- define "customPodLabelsContainsApp" -}}
{{- $LabelsContain := false -}}
{{- if hasKey .Values.customPodLabels "app" }}
{{- $LabelsContain = true -}}
{{- end }}
{{- $LabelsContain -}}
{{- end -}}
{{- define "customPodLabelsContainsRelease" -}}
{{- $LabelsContain := false -}}
{{- if hasKey .Values.customPodLabels "release" }}
{{- $LabelsContain = true -}}
{{- end }}
{{- $LabelsContain -}}
{{- end -}}
{{- define "vmserviceScrapeEnabled" -}}
{{- $SMenabled := false -}}
{{- range .Values.ContainerPort }}
{{- if .vmservicescrape }}
{{- if and .vmservicescrape.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- end }}
{{- end }}
{{- $SMenabled -}}
{{- end -}}
{{- define "podMonitorEnabled" -}}
{{- $SMenabled := false -}}
{{- if .Values.podmonitor.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- $SMenabled -}}
{{- end -}}
{{- define "scrapeType" -}}
{{- $ServiceMonitorEnabled := include "serviceMonitorEnabled" . -}}
{{- $VmServiceScrapeEnabled := include "vmserviceScrapeEnabled" . -}}
{{- $val1 := "vmservicescrape"}}
{{- $val2 := "servicemonitor"}}
{{- $val3 := "" }}
{{- if and (eq $VmServiceScrapeEnabled "true") (eq $ServiceMonitorEnabled "true")}}
{{- $val1 }}
{{- else if eq $ServiceMonitorEnabled "true" }}
{{- $val2 }}
{{- else if eq $VmServiceScrapeEnabled "true" }}
{{- $val1 }}
{{- else }}
{{- $val3 }}
{{- end }}
{{- end }}