-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy path_helpers.tpl
More file actions
237 lines (216 loc) · 5.97 KB
/
_helpers.tpl
File metadata and controls
237 lines (216 loc) · 5.97 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "trident.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- 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 "trident.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 "trident.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "trident.labels" -}}
helm.sh/chart: {{ include "trident.chart" . }}
{{ include "trident.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "trident.selectorLabels" -}}
app.kubernetes.io/name: {{ include "trident.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Trident operator level
*/}}
{{- define "trident-operator.logLevel" -}}
{{- .Values.operatorLogLevel }}
{{- end }}
{{/*
Trident operator debug
*/}}
{{- define "trident-operator.debug" -}}
{{- .Values.operatorDebug }}
{{- end }}
{{/*
Trident operator image
*/}}
{{- define "trident-operator.image" -}}
{{- if .Values.operatorImage }}
{{- .Values.operatorImage }}:{{ .Values.operatorImageTag | default .Chart.AppVersion }}
{{- else if .Values.imageRegistry }}
{{- .Values.imageRegistry }}/trident-operator:{{ .Values.operatorImageTag | default .Chart.AppVersion }}
{{- else }}
{{- "" }}docker.io/netapp/trident-operator:{{ .Values.operatorImageTag | default .Chart.AppVersion }}
{{- end }}
{{- end }}
{{/*
Trident force detach
*/}}
{{- define "trident.enableForceDetach" -}}
{{- if .Values.enableForceDetach | printf "%v" | eq "true" }}
{{- "true" }}
{{- else }}
{{- "false" }}
{{- end }}
{{- end }}
{{/*
Trident IPv6
*/}}
{{- define "trident.IPv6" -}}
{{- if .Values.tridentIPv6 | printf "%v" | eq "true" }}
{{- "true" }}
{{- else }}
{{- "false" }}
{{- end }}
{{- end }}
{{/*
Trident SilenceAutosupport
*/}}
{{- define "trident.silenceAutosupport" -}}
{{- if .Values.tridentSilenceAutosupport | printf "%v" | eq "true" }}
{{- "true" }}
{{- else }}
{{- "false" }}
{{- end }}
{{- end }}
Trident AutoSupport image
*/}}
{{- define "trident.autosupportImage" -}}
{{- if .Values.tridentAutosupportImage }}
{{- .Values.tridentAutosupportImage }}:{{ .Values.tridentAutosupportImageTag | default .Chart.AppVersion | trunc 5}}
{{- else if .Values.imageRegistry }}
{{- .Values.imageRegistry }}/trident-autosupport:{{ .Values.tridentAutosupportImageTag | default .Chart.AppVersion | trunc 5}}
{{- else }}
{{- "" }}docker.io/netapp/trident-autosupport:{{ .Values.tridentAutosupportImageTag | default .Chart.AppVersion | trunc 5}}
{{- end }}
{{- end }}
{{/*
Trident log level
*/}}
{{- define "trident.logLevel" -}}
{{- .Values.tridentLogLevel }}
{{- end }}
{{/*
Trident debug (equivalent to debug level)
*/}}
{{- define "trident.debug" -}}
{{- .Values.tridentDebug }}
{{- end }}
{{/*
Trident logging workflows
*/}}
{{- define "trident.logWorkflows" -}}
{{- .Values.tridentLogWorkflows }}
{{- end }}
{{/*
Trident logging layers
*/}}
{{- define "trident.logLayers" -}}
{{- .Values.tridentLogLayers }}
{{- end }}
{{/*
Trident log format
*/}}
{{- define "trident.logFormat" -}}
{{- if eq .Values.tridentLogFormat "json" }}
{{- .Values.tridentLogFormat }}
{{- else }}
{{- "text" }}
{{- end }}
{{- end }}
{{/*
Trident audit log
*/}}
{{- define "trident.disableAuditLog" -}}
{{- if .Values.tridentDisableAuditLog | printf "%v" | eq "true" }}
{{- "true" }}
{{- else }}
{{- "false" }}
{{- end }}
{{- end }}
{{/*
Trident probe port
*/}}
{{- define "trident.probePort" -}}
{{- if eq .Values.tridentProbePort "json" }}
{{- .Values.tridentProbePort }}
{{- else }}
{{- 17546 }}
{{- end }}
{{- end }}
{{/*
Trident image
*/}}
{{- define "trident.image" -}}
{{- if .Values.tridentImage }}
{{- .Values.tridentImage }}:{{ .Values.tridentImageTag | default .Chart.AppVersion }}
{{- else if .Values.imageRegistry }}
{{- .Values.imageRegistry }}/trident:{{ .Values.tridentImageTag | default .Chart.AppVersion }}
{{- else }}
{{- "" }}docker.io/netapp/trident:{{ .Values.tridentImageTag | default .Chart.AppVersion }}
{{- end }}
{{- end }}
{{/*
Trident image pull policy
*/}}
{{- define "imagePullPolicy" -}}
{{- if .Values.imagePullPolicy }}
{{- .Values.imagePullPolicy }}
{{- else }}
{{- "IfNotPresent" }}
{{- end }}
{{- end }}
{{/*
Determines if rancher roles should be created by checking for the presence of the cattle-system namespace
or annotations with the prefix "cattle.io/" in the namespace where the chart is being installed.
Override auto-detection and force install the roles by setting Values.forceInstallRancherClusterRoles to 'true'.
*/}}
{{- define "shouldInstallRancherRoles" -}}
{{- $isRancher := false -}}
{{- $currentNs := .Release.Namespace -}}
{{- $currentNsObj := lookup "v1" "Namespace" "" $currentNs -}}
{{- /* Check if 'forceInstallRancherClusterRoles' is set */ -}}
{{- if .Values.forceInstallRancherClusterRoles }}
{{- $isRancher = true -}}
{{- end }}
{{- /* Check if the annotation prefix "cattle.io/" exists on the namespace */ -}}
{{- if $currentNsObj }}
{{- range $key, $value := $currentNsObj.metadata.annotations }}
{{- if hasPrefix "cattle.io/" $key }}
{{- $isRancher = true -}}
{{- end }}
{{- end }}
{{- end }}
{{- /* Check if cattle-system ns exists */ -}}
{{- $cattleNs := lookup "v1" "Namespace" "" "cattle-system" -}}
{{- if $cattleNs }}
{{- $isRancher = true -}}
{{- end }}
{{- $isRancher -}}
{{- end }}