-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path_helpers.tpl
509 lines (472 loc) · 22.7 KB
/
_helpers.tpl
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
{{/* Validation for secretKeyRef to avoid conflicting secret names with secrets created by controllers */}}
{{- define "codefresh-gitops-runtime.secret-name-validation"}}
{{- $reservedSecretNames := list "codefresh-token" }}
{{- if has .name $reservedSecretNames }}
{{- fail (printf "%s is a reserved name and is not allowed. Please use a different secret name" .name) }}
{{- end }}
{{- end }}
{{/*
Expand the name of the chart.
*/}}
{{- define "codefresh-gitops-runtime.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 "codefresh-gitops-runtime.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 "codefresh-gitops-runtime.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "codefresh-gitops-runtime.labels" -}}
helm.sh/chart: {{ include "codefresh-gitops-runtime.chart" . }}
{{ include "codefresh-gitops-runtime.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: codefresh-gitops-runtime
{{- end }}
{{/*
Selector labels
*/}}
{{- define "codefresh-gitops-runtime.selectorLabels" -}}
app: "codefresh-gitops-runtime"
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "codefresh-gitops-runtime.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "codefresh-gitops-runtime.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{- define "codefresh-gitops-runtime.installation-token-secret-name" }}
{{- print "codefresh-user-token" }}
{{- end }}
{{/*
Determine argocd server service name. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.servicename" -}}
{{/* For now use template from ArgoCD chart until better approach */}}
{{- template "argo-cd.server.fullname" (dict "Values" (get .Values "argo-cd") "Release" .Release ) }}
{{- end }}
{{/*
Determine argocd redis service name. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.redis.servicename" -}}
{{/* For now use template from ArgoCD chart until better approach */}}
{{- template "argo-cd.redis.fullname" (dict "Values" (get .Values "argo-cd") "Release" .Release ) }}
{{- end }}
{{/*
Determine argocd repo server service name. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.reposerver.servicename" -}}
{{/* For now use template from ArgoCD chart until better approach */}}
{{- if and (index .Subcharts "argo-cd") }}
{{- template "argo-cd.repoServer.fullname" (dict "Values" (get .Values "argo-cd") "Release" .Release ) }}
{{- else }}
{{- $repoServer := index .Values "global" "external-argo-cd" "repoServer" }}
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.svc }}
{{- printf "%s" $svc }}
{{- end }}
{{- end }}
{{/*
Determine argocd argocd repo server port
*/}}
{{- define "codefresh-gitops-runtime.argocd.reposerver.serviceport" -}}
{{/* For now use template from ArgoCD chart until better approach */}}
{{- if and (index .Subcharts "argo-cd") }}
{{- index .Values "argo-cd" "repoServer" "service" "port" }}
{{- else }}
{{- $repoServer := index .Values "global" "external-argo-cd" "repoServer" }}
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.port }}
{{- printf "%v" $port }}
{{- end }}
{{- end }}
{{/*
Determine argocd repoServer url
*/}}
{{- define "codefresh-gitops-runtime.argocd.reposerver.url" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- $serviceName := include "codefresh-gitops-runtime.argocd.reposerver.servicename" . }}
{{- $port := include "codefresh-gitops-runtime.argocd.reposerver.serviceport" . }}
{{- printf "%s:%s" $serviceName $port }}
{{- else if and (index .Values "global" "external-argo-cd" "repoServer") }}
{{- $repoServer := (index .Values "global" "external-argo-cd" "repoServer") }}
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.svc }}
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.port is not set" $repoServer.port }}
{{- printf "%s:%v" $svc $port }}
{{- else }}
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer is not set" }}
{{- end }}
{{- end}}
{{/*
Determine argocd servicename. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.appcontroller.serviceAccountName" -}}
{{/* For now use template from ArgoCD chart until better approach */}}
{{- template "argo-cd.controllerServiceAccountName" (dict "Values" (get .Values "argo-cd") "Release" .Release ) }}
{{- end }}
{{/*
Determine rollouts name
*/}}
{{- define "codefresh-gitops-runtime.argo-rollouts.name" -}}
{{/* For now use template from rollouts chart until better approach */}}
{{- if and (index .Values "argo-rollouts" "enabled") }}
{{- template "argo-rollouts.fullname" (dict "Values" (get .Values "argo-rollouts")) }}
{{- else }}
{{- printf "%s" (index .Values "event-reporters" "rollout" "external-argo-rollouts" "fullnameOverride") }}
{{- end }}
{{- end }}
{{/*
Determine argocd server service port. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.serviceport" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- $port := 443 }}
{{- if hasKey $argoCDValues "configs" }}
{{- if hasKey $argoCDValues.configs "params" }}
{{- if hasKey $argoCDValues.configs.params "server.insecure" }}
{{- if (get $argoCDValues.configs.params "server.insecure") }}
{{- $port = 80 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- print $port }}
{{- end}}
{{/*
Determine argocd redis service port. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.redis.serviceport" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- $port := $argoCDValues.redis.servicePort }}
{{- print $port }}
{{- end}}
{{/*
Determine argocd server url. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.url" -}}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- $protocol := "https" }}
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
{{- if (eq $port "80") }}
{{- $protocol = "http" }}
{{- end }}
{{- $url := include "codefresh-gitops-runtime.argocd.server.no-protocol-url" . }}
{{- printf "%s://%s" $protocol $url }}
{{- else if and (index .Values "global" "external-argo-cd" "server") }}
{{- $argoCDSrv := (index .Values "global" "external-argo-cd" "server") }}
{{- $protocol := "http" }}
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.svc is not set" $argoCDSrv.svc }}
{{- $port := (required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.port is not port" $argoCDSrv.port) | toString }}
{{- $rootpath := (index .Values "global" "external-argo-cd" "server" "rootpath") }}
{{- if and (eq $port "80") }}
{{- printf "%s://%s%s" $protocol $svc $rootpath }}
{{- else }}
{{- printf "%s://%s:%s%s" $protocol $svc $port $rootpath }}
{{- end }}
{{- else }}
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set" }}
{{- end }}
{{- end}}
{{/*
Determine argocd server url witout the protocol. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.no-protocol-url" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- $serverName := include "codefresh-gitops-runtime.argocd.server.servicename" . }}
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
{{- $path := (get $argoCDValues.configs.params "server.rootpath") }}
{{- printf "%s:%s%s" $serverName $port $path }}
{{- else if and (index .Values "global" "external-argo-cd" "server") }}
{{- $argoCDSrv := (index .Values "global" "external-argo-cd" "server") }}
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.svc is not set" $argoCDSrv.svc }}
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.port is not set" $argoCDSrv.port }}
{{- $rootpath := (index .Values "global" "external-argo-cd" "server" "rootpath") }}
{{- printf "%s:%v%s" $svc $port $rootpath }}
{{- else }}
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set" }}
{{- end }}
{{- end}}
{{/*
Determine argocd server password.
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.password" }}
{{- if and (index .Values "argo-cd" "enabled") }}
valueFrom:
secretKeyRef:
name: argocd-initial-admin-secret
key: password
{{- else if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "password") (index .Values "global" "external-argo-cd" "auth" "passwordSecretKeyRef") }}
valueFrom:
secretKeyRef:
{{- index .Values "global" "external-argo-cd" "auth" "passwordSecretKeyRef" | toYaml | nindent 4 }}
{{- else if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "password") (index .Values "global" "external-argo-cd" "auth" "password") }}
valueFrom:
secretKeyRef:
name: gitops-runtime-argo-cd-password
key: token
{{- else if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "token") (index .Values "global" "external-argo-cd" "auth" "token") }}
valueFrom:
secretKeyRef:
name: gitops-runtime-argo-cd-token
key: token
{{- else if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "token") (index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef") }}
valueFrom:
secretKeyRef:
{{- index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" | toYaml | nindent 4 }}
optional: true
{{- else }}
{{ fail "ArgoCD is not enabled and .Values.global.external-argo-cd.auth.password or .Values.global.external-argo-cd.auth.passwordSecretKeyRef is not set" }}
{{- end }}
{{- end }}
{{/*
Determine argocd token password.
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.token" }}
{{- if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "token") (index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" "name") (index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" "key")}}
valueFrom:
secretKeyRef:
{{- index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" | toYaml | nindent 4 }}
{{- else if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "token") (index .Values "global" "external-argo-cd" "auth" "token") }}
valueFrom:
secretKeyRef:
name: gitops-runtime-argo-cd-token
key: token
{{- else if or (eq (index .Values "global" "external-argo-cd" "auth" "type") "password") }}
valueFrom:
secretKeyRef:
name: argocd-token
key: token
optional: true
{{- else }}
{{ fail (printf "Invalid value for .Values.global.external-argo-cd.auth.type: %s. Allowed values are: [password token]" (index .Values "global" "external-argo-cd" "auth" "type")) }}
{{- end }}
{{- end }}
{{/*
Determine argocd server password.
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.username-env-var" }}
{{- if and (index .Values "argo-cd" "enabled") }}
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoCdUsername
optional: true
{{- else if and (index .Values "global" "external-argo-cd" "auth" "usernameSecretKeyRef") }}
valueFrom:
secretKeyRef:
{{- index .Values "global" "external-argo-cd" "auth" "usernameSecretKeyRef" | toYaml | nindent 4 }}
{{- else if and (index .Values "global" "external-argo-cd" "auth" "username") }}
{{- printf "%s" (index .Values "global" "external-argo-cd" "auth" "username") }}
{{- else }}
{{ fail "ArgoCD is not enabled and .Values.global.external-argo-cd.auth.username or .Values.global.external-argo-cd.auth.usernameSecretKeyRef is not set" }}
{{- end }}
{{- end }}
{{/*
Determine argocd server password.
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.username-cm" }}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- printf "%s" (index .Values "app-proxy" "config" "argoCdUsername") }}
{{- else if and (index .Values "global" "external-argo-cd" "auth" "username") }}
{{- printf "%s" (index .Values "global" "external-argo-cd" "auth" "username") }}
{{- else }}
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.auth.username is not set" }}
{{- end }}
{{- end }}
{{/*
Determine argocd redis url
*/}}
{{- define "codefresh-gitops-runtime.argocd.redis.url" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- $serviceName := include "codefresh-gitops-runtime.argocd.redis.servicename" . }}
{{- $port := include "codefresh-gitops-runtime.argocd.redis.serviceport" . }}
{{- printf "%s:%s" $serviceName $port }}
{{- else if and (index .Values "global" "external-argo-cd" "redis") }}
{{- $redis := (index .Values "global" "external-argo-cd" "redis") }}
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.redis.svc is not set" $redis.svc }}
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.redis.port is not set" $redis.port }}
{{- printf "%s:%v" $svc $port }}
{{- else }}
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.redis is not set" }}
{{- end }}
{{- end}}
{{/*
Determine argo worklofws server name
*/}}
{{- define "codefresh-gitops-runtime.argo-workflows.server.name" -}}
{{/* For now use template from argo worklow chart until better approach */}}
{{- template "argo-workflows.server.fullname" (dict "Values" (get .Values "argo-workflows")) }}
{{- end }}
{{/*
Determine argo workflows server url. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argo-workflows.server.url" -}}
{{- $protocol := "http" }}
{{- if index (get .Values "argo-workflows") "server" "secure" }}
{{- $protocol = "https" }}
{{- end -}}
{{/* For now use template from Argo workflows chart until better approach */}}
{{- printf "%s://%s:2746" $protocol (include "codefresh-gitops-runtime.argo-workflows.server.name" .) }}
{{- end }}
{{/*
Determine app proxy url. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.app-proxy.url" -}}
{{/* Using templates from app-proxy */}}
{{- printf "http://%s:%s" (include "cap-app-proxy.fullname" (dict "Values" (get .Values "app-proxy"))) (index (get .Values "app-proxy") "service" "port" | toString ) }}
{{- end }}
{{/*
Environemnt variable value of Codefresh installation token
*/}}
{{- define "codefresh-gitops-runtime.installation-token-env-var-value" -}}
{{- if .Values.global.codefresh.userToken.token }}
valueFrom:
secretKeyRef:
name: {{ include "codefresh-gitops-runtime.installation-token-secret-name" . }}
key: token
optional: true
{{- else if .Values.global.codefresh.userToken.secretKeyRef }}
{{- include "codefresh-gitops-runtime.secret-name-validation" .Values.global.codefresh.userToken.secretKeyRef }}
valueFrom:
secretKeyRef:
{{- .Values.global.codefresh.userToken.secretKeyRef | toYaml | nindent 4 }}
{{- else }}
{{- fail "global.codefresh.userToken is mandatory. Set token or secretKeyRef!" }}
{{- end }}
{{- end }}
{{/*
Get ingress url for both tunnel based and ingress based runtimes
*/}}
{{- define "codefresh-gitops-runtime.ingress-url"}}
{{- $supportedProtocols := list "http" "https" }}
{{- if .Values.global.runtime.ingress.enabled }}
{{- if has .Values.global.runtime.ingress.protocol $supportedProtocols }}
{{- printf "%s://%s" .Values.global.runtime.ingress.protocol (index .Values.global.runtime.ingress.hosts 0)}}
{{- else }}
{{ fail (printf "ERROR: Unsupported protocol %s for ingress. Only http and https supported" .Values.global.runtime.ingress.protocol)}}
{{- end }}
{{/* If tunnel client is enabled - ingress url is <accoundId>-<runtimename>.<tunnel-subdomain> */}}
{{- else if index .Values "tunnel-client" "enabled" }}
{{- $accoundId := required "global.codefresh.accountId is required for tunnel based runtime" .Values.global.codefresh.accountId }}
{{- $runtimeName := required "global.runtime.name is required for tunnel based runtime" .Values.global.runtime.name }}
{{- $tunnelPrefix := printf "%s-%s" .Values.global.codefresh.accountId .Values.global.runtime.name }}
{{- $tunnelHost := index (get .Values "tunnel-client") "tunnelServer" "subdomainHost"}}
{{- printf "https://%s.%s" $tunnelPrefix $tunnelHost }}
{{- else }}
{{/* If ingress is disabled and tunnel-client is disabled, the ingressHost must be explicitly defined in the values*/}}
{{- if .Values.global.runtime.ingressUrl }}
{{- if or (hasPrefix "http" .Values.global.runtime.ingressUrl) (hasPrefix "https" .Values.global.runtime.ingressUrl)}}
{{- print .Values.global.runtime.ingressUrl }}
{{- else }}
{{- fail "ERROR: Only http and https are supported for global.runtime.ingressUrl"}}
{{- end }}
{{- else }}
{{- fail "ERROR: When global.runtime.ingress.enabled is false and tunnel-client.enabled is false - global.runtime.ingressUrl must be provided" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Output comma separated list of installed runtime components
*/}}
{{- define "codefresh-gitops-runtime.component-list"}}
{{- $argoEvents := dict "name" "argo-events" "version" (get .Subcharts "argo-events").Chart.AppVersion }}
{{- $sealedSecrets := dict "name" "sealed-secrets" "version" (get .Subcharts "sealed-secrets").Chart.AppVersion }}
{{- $internalRouter := dict "name" "internal-router" "version" .Chart.AppVersion }}
{{- $appProxy := dict "name" "app-proxy" "version" (index (get .Values "app-proxy") "image" "tag") }}
{{- $sourcesServer := dict "name" "sources-server" "version" (get .Subcharts "cf-argocd-extras").Chart.AppVersion }}
{{- $comptList := list $argoEvents $appProxy $sealedSecrets $internalRouter $sourcesServer }}
{{- if and (index .Values "argo-cd" "enabled") }}
{{- $argoCD := dict "name" "argocd" "version" (get .Subcharts "argo-cd").Chart.AppVersion }}
{{- $comptList = append $comptList $argoCD }}
{{- end }}
{{- if index (get .Values "argo-rollouts") "enabled" }}
{{- $rolloutReporter := dict "name" "rollout-reporter" "version" .Chart.AppVersion }}
{{- $argoRollouts := dict "name" "argo-rollouts" "version" (get .Subcharts "argo-rollouts").Chart.AppVersion }}
{{- $comptList = append $comptList $argoRollouts }}
{{- $comptList = append $comptList $rolloutReporter }}
{{- end }}
{{- if index (get .Values "argo-workflows") "enabled" }}
{{- $workflowReporter := dict "name" "workflow-reporter" "version" .Chart.AppVersion }}
{{- $argoWorkflows := dict "name" "argo-workflows" "version" (get .Subcharts "argo-workflows").Chart.AppVersion }}
{{- $comptList = append $comptList $workflowReporter}}
{{- $comptList = append $comptList $argoWorkflows }}
{{- end }}
{{- if and ( not .Values.global.runtime.ingress.enabled) (index .Values "tunnel-client" "enabled") }}
{{- $tunnelClient := dict "name" "codefresh-tunnel-client" "version" (get .Subcharts "tunnel-client").Chart.AppVersion }}
{{- $comptList = append $comptList $tunnelClient }}
{{- end }}
{{- if index (get .Values "gitops-operator") "enabled" }}
{{- $gitopsOperator := dict "name" "gitops-operator" "version" (get .Subcharts "gitops-operator").Chart.AppVersion }}
{{- $comptList = append $comptList $gitopsOperator }}
{{- end }}
{{- if not (index .Values "argo-cd" "enabled") }}
{{- $eventReporter := dict "name" "event-reporter" "version" (get .Subcharts "cf-argocd-extras").Chart.AppVersion }}
{{- $comptList = append $comptList $eventReporter }}
{{- end }}
{{- $comptList | toYaml }}
{{- end }}
# ------------------------------------------------------------------------------------------------------------
# runtime git credentials
# ------------------------------------------------------------------------------------------------------------
{{- define "codefresh-gitops-runtime.runtime-gitcreds.password.default-secret-name" }}
{{- printf "%s-git-password" .Values.global.runtime.name }}
{{- end }}
{{- define "codefresh-gitops-runtime.runtime-gitcreds.password.secretname" }}
{{- if .Values.global.runtime.gitCredentials.password.value}}
{{- include "codefresh-gitops-runtime.runtime-gitcreds.password.default-secret-name" . }}
{{- else if .Values.global.runtime.gitCredentials.password.secretKeyRef }}
{{- if hasKey .Values.global.runtime.gitCredentials.password.secretKeyRef "name" }}
{{- include "codefresh-gitops-runtime.secret-name-validation" .Values.global.runtime.gitCredentials.password.secretKeyRef }}
{{- print .Values.global.runtime.gitCredentials.password.secretKeyRef.name }}
{{- else }}
{{ fail "secretKeyRef for global.runtime.gitCredentials.password illegal - must have name field"}}
{{- end }}
{{- end }}
{{- end }}
{{- define "codefresh-gitops-runtime.runtime-gitcreds.password.secretkey" }}
{{- if .Values.global.runtime.gitCredentials.password.value}}
{{- print "password" }}
{{- else if .Values.global.runtime.gitCredentials.password.secretKeyRef }}
{{- if hasKey .Values.global.runtime.gitCredentials.password.secretKeyRef "key" }}
{{- print .Values.global.runtime.gitCredentials.password.secretKeyRef.key }}
{{- else }}
{{ fail "secretKeyRef for global.runtime.gitCredentials.password illegal - must have key field"}}
{{- end }}
{{- end }}
{{- end }}
{{- define "codefresh-gitops-runtime.runtime-gitcreds.password.env-var-value"}}
valueFrom:
secretKeyRef:
name: {{ include "codefresh-gitops-runtime.runtime-gitcreds.password.secretname" . }}
key: {{ include "codefresh-gitops-runtime.runtime-gitcreds.password.secretkey" . }}
optional: true
{{- end }}
# ------------------------------------------------------------------------------------------------------------