-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path_helpers.tpl
More file actions
266 lines (240 loc) · 7.57 KB
/
_helpers.tpl
File metadata and controls
266 lines (240 loc) · 7.57 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
{{/*
Expand the name of the chart.
*/}}
{{- define "fides.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name for Fides
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 "fides.fullname" -}}
{{- $baseName := default .Chart.Name .Values.nameOverride }}
{{- if .Values.fides.fullnameOverride }}
{{- $baseName = .Values.fides.fullnameOverride }}
{{- else }}
{{- if contains $baseName .Release.Name }}
{{- $baseName = .Release.Name }}
{{- else }}
{{- $baseName = printf "%s-%s" .Release.Name $baseName }}
{{- end }}
{{- end }}
{{- $baseName | trunc 63 | trimSuffix "-"}}
{{- end }}
{{/*
Create a default fully qualified app name for Fides Workers
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 "fides.worker.fullname" -}}
{{- printf "worker-%s" ( include "fides.fullname" . ) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name for the Privacy Center
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 "fides.privacyCenter.fullname" -}}
{{- printf "pc-%s" ( include "fides.fullname" . ) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "fides.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
The Docker tag from which to pull the image.
*/}}
{{- define "fides.dockerTag" -}}
{{ .Values.fides.image.tag | default .Chart.AppVersion }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "fides.labels" -}}
helm.sh/chart: {{ include "fides.chart" . }}
{{ include "fides.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Base Selector labels
*/}}
{{- define "fides.selectorLabels" -}}
app.kubernetes.io/name: {{ include "fides.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Fides Selector labels
*/}}
{{- define "fides.fides.selectorLabels" -}}
{{ include "fides.selectorLabels" . }}
app.kubernetes.io/component: "fides"
{{- end }}
{{/*
Privacy Center Selector labels
*/}}
{{- define "fides.privacyCenter.selectorLabels" -}}
{{ include "fides.selectorLabels" . }}
app.kubernetes.io/component: "privacy-center"
{{- end }}
{{/*
Fides Worker Selector labels
*/}}
{{- define "fides.worker.selectorLabels" -}}
{{ include "fides.selectorLabels" . }}
app.kubernetes.io/component: "fides-worker"
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "fides.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "fides.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/*
Control the deployment strategy
*/}}
{{- define "fides.deploymentStrategy" -}}
type: {{ ternary "RollingUpdate" "Recreate" .Values.useRollingUpdate}}
{{- if .Values.useRollingUpdate }}
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
{{- end }}
{{- end }}
{{/*
Create the name of the secret to store FIDES__SECURITY environment variables
*/}}
{{- define "fides.fidesSecuritySecretName" -}}
{{ default (printf "fides-security-%s" ( include "fides.fullname" . ) | trunc 63 | trimSuffix "-") .Values.fides.configuration.fidesSecuritySecretName }}
{{- end }}
{{/*
Create the name of the config map to store the fides.toml file.
*/}}
{{- define "fides.tomlConfigMapName" -}}
{{ printf "fides-toml-%s" ( include "fides.fullname" . ) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create the name of the config map to store the fides.toml file.
*/}}
{{- define "fides.worker.tomlConfigMapName" -}}
{{ printf "worker-%s" (include "fides.tomlConfigMapName" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
List of CORS origins, concatenated, deduplicated, and formatted.
*/}}
{{- define "fides.corsOrigins" -}}
{{- $cors := list }}
{{- if .Values.privacyCenter.publicHostname }}
{{- $cors = append $cors (printf "https://%s" .Values.privacyCenter.publicHostname | quote) }}
{{- end }}
{{- if .Values.fides.publicHostname }}
{{- $cors = append $cors (printf "https://%s" .Values.fides.publicHostname | quote) }}
{{- end }}
{{- if eq .Values.fides.service.type "LoadBalancer" }}
{{- if .Values.fides.publicHostname }}
{{- $cors = append $cors (printf "http://%s" .Values.fides.publicHostname | quote) }}
{{- end }}
{{- if and .Values.privacyCenter.enabled .Values.privacyCenter.publicHostname }}
{{- $cors = append $cors (printf "http://%s" .Values.privacyCenter.publicHostname | quote) }}
{{- end }}
{{- end }}
{{- range (.Values.fides.configuration.additionalCORSOrigins | compact) }}
{{- $cors = append $cors (. | quote) }}
{{- end }}
{{- $cors = $cors | compact | uniq }}
{{ printf "[%s]" (join "," $cors) }}
{{- end }}
{{/*
The set of environment variables for Fides and workers
*/}}
{{- define "fides.env" -}}
{{- $namespace := .Release.Namespace }}
{{- $releaseName := .Release.Name }}
{{- $redisDeployment := .Values.redis }}
{{- $pgDeployment := .Values.postgresql }}
{{- with .Values.fides.configuration }}
{{- include "fides.processedEnvVars" $ }}
- name: FIDES__DATABASE__SERVER
valueFrom:
secretKeyRef:
name: {{ .dbSecretName }}
key: DB_HOST
- name: FIDES__DATABASE__PORT
valueFrom:
secretKeyRef:
name: {{ .dbSecretName }}
key: DB_PORT
- name: FIDES__DATABASE__USER
valueFrom:
secretKeyRef:
name: {{ .dbSecretName }}
key: DB_USERNAME
- name: FIDES__DATABASE__PASSWORD
valueFrom:
secretKeyRef:
name: {{ .dbSecretName }}
key: DB_PASSWORD
- name: FIDES__DATABASE__DB
valueFrom:
secretKeyRef:
name: {{ .dbSecretName }}
key: DB_DATABASE
- name: FIDES__REDIS__HOST
valueFrom:
secretKeyRef:
name: {{ .redisSecretName }}
key: REDIS_HOST
- name: FIDES__REDIS__PORT
valueFrom:
secretKeyRef:
name: {{ .redisSecretName }}
key: REDIS_PORT
- name: FIDES__REDIS__PASSWORD
valueFrom:
secretKeyRef:
name: {{ .redisSecretName }}
key: REDIS_PASSWORD
{{- end }}
{{- end }}
{{/*
Detect if fidesplus is being used based on the repository name
*/}}
{{- define "fides.isFidesplus" -}}
{{- if contains "fidesplus" (.Values.fides.image.repository | lower) -}}
true
{{- else -}}
false
{{- end -}}
{{- end }}
{{/*
Get processed environment variables with additional settings
*/}}
{{- define "fides.processedEnvVars" -}}
{{- $envVars := .Values.fides.configuration.additionalEnvVars | default list }}
{{- $hiddenEnvVar := dict "name" "FIDES__EXECUTION__MONITOR_CELERY_TASKS_ENABLED" "value" "true" }}
{{- $envVars = append $envVars $hiddenEnvVar }}
{{- $envVars | toYaml }}
{{- end }}
{{/*
Validates that all worker types have unique names. Fails if duplicate names are found.
*/}}
{{- define "fides.worker.validateUniqueNames" -}}
{{- $workers := .Values.fides.workerConfiguration.workers | default list }}
{{- $names := dict }}
{{- range $workers }}
{{- if hasKey $names .name }}
{{- fail (printf "Duplicate worker name found: '%s'. Worker names must be unique" .name) }}
{{- else }}
{{- $_ := set $names .name "used" }}
{{- end }}
{{- end }}
{{- end }}