Skip to content

Commit 7aa6da1

Browse files
committed
only use global.external-argo-cd.auth values if argo-cd.enabled is false
1 parent 6cf1d75 commit 7aa6da1

File tree

5 files changed

+208
-31
lines changed

5 files changed

+208
-31
lines changed

charts/gitops-runtime/templates/_components/cf-argocd-extras/event-reporter/_statefulset.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
{{- $_ := set $context.Values.container.env.REDIS_PASSWORD.valueFrom.secretKeyRef "key" (default "redis-password" $vals.externalRedis.existingSecretKeyRef.key) }}
1616
{{- end }}
1717

18-
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
19-
{{- if (eq $argoCdAuth.type "token") }}
20-
{{- if $argoCdAuth.token }}
21-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
22-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
23-
{{- else if $argoCdAuth.tokenSecretKeyRef }}
24-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
25-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
26-
{{- else }}
27-
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
18+
{{- if not (index .Values "argo-cd" "enabled") }}
19+
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
20+
{{- if (eq $argoCdAuth.type "token") }}
21+
{{- if $argoCdAuth.token }}
22+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
23+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
24+
{{- else if $argoCdAuth.tokenSecretKeyRef }}
25+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
26+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
27+
{{- else }}
28+
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
29+
{{- end }}
2830
{{- end }}
2931
{{- end }}
3032

charts/gitops-runtime/templates/_components/cf-argocd-extras/sources-server/_deployment.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
{{- $_ := set $context.Values.container.env.REDIS_PASSWORD.valueFrom.secretKeyRef "key" (default "redis-password" $vals.externalRedis.existingSecretKeyRef.key) }}
1616
{{- end }}
1717

18-
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
19-
{{- if (eq $argoCdAuth.type "token") }}
20-
{{- if $argoCdAuth.token }}
21-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
22-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
23-
{{- else if $argoCdAuth.tokenSecretKeyRef }}
24-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
25-
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
26-
{{- else }}
27-
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
18+
{{- if not (index .Values "argo-cd" "enabled") }}
19+
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
20+
{{- if (eq $argoCdAuth.type "token") }}
21+
{{- if $argoCdAuth.token }}
22+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
23+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
24+
{{- else if $argoCdAuth.tokenSecretKeyRef }}
25+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
26+
{{- $_ := set $context.Values.container.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
27+
{{- else }}
28+
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
29+
{{- end }}
2830
{{- end }}
2931
{{- end }}
3032

charts/gitops-runtime/templates/_helpers.tpl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,20 @@ Determine argocd server url witout the protocol. Must be called with chart root
236236
{{- end}}
237237

238238
{{- define "codefresh-gitops-runtime.argocd-auth" -}}
239+
{{- $internalArgoCd := (index $.Values "argo-cd" "enabled") }}
239240
{{- $authValues := (index .Values "global" "external-argo-cd" "auth") }}
240-
{{- if (eq $authValues.type "password") }}
241+
{{- if $internalArgoCd }}
242+
ARGO_CD_USERNAME:
243+
valueFrom:
244+
configMapKeyRef:
245+
name: cap-app-proxy-cm
246+
key: argoCdUsername
247+
ARGO_CD_PASSWORD:
248+
valueFrom:
249+
secretKeyRef:
250+
name: argocd-initial-admin-secret
251+
key: password
252+
{{- else if (eq $authValues.type "password") }}
241253
ARGO_CD_USERNAME:
242254
valueFrom:
243255
configMapKeyRef:

charts/gitops-runtime/templates/gitops-operator/deployment.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
99
{{- $_ := set $context.Values "app-proxy" (deepCopy (get .Values "app-proxy")) }}
1010

11-
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
12-
{{- if (eq $argoCdAuth.type "token") }}
13-
{{- if $argoCdAuth.token }}
14-
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
15-
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
16-
{{- else if $argoCdAuth.tokenSecretKeyRef }}
17-
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
18-
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
19-
{{- else }}
20-
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
11+
{{- if not (index .Values "argo-cd" "enabled") }}
12+
{{- $argoCdAuth := (index .Values "global" "external-argo-cd" "auth") }}
13+
{{- if (eq $argoCdAuth.type "token") }}
14+
{{- if $argoCdAuth.token }}
15+
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_NAME" "gitops-runtime-argo-cd-token" }}
16+
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_KEY" "token" }}
17+
{{- else if $argoCdAuth.tokenSecretKeyRef }}
18+
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_NAME" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" $argoCdAuth.tokenSecretKeyRef.name) }}
19+
{{- $_ := set $context.Values.env "ARGO_CD_TOKEN_SECRET_KEY" (required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore .Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" $argoCdAuth.tokenSecretKeyRef.key) }}
20+
{{- else }}
21+
{{ fail ".Values.global.external-argo-cd.auth.type is 'token' and .Values.global.external-argo-cd.auth.token or .Values.global.external-argo-cd.auth.tokenSecretKeyRef are not set" }}
22+
{{- end }}
2123
{{- end }}
2224
{{- end }}
2325

charts/gitops-runtime/tests/external_argocd_test.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,50 @@ tests:
117117
key: password
118118
name: argocd-initial-admin-secret
119119

120+
- it: app-proxy Deployment should have valid deafult ARGO_CD_USERNAME env var if auth.type is password with internal argo-cd
121+
values:
122+
- ./values/mandatory-values-ingress.yaml
123+
set:
124+
global:
125+
external-argo-cd:
126+
auth:
127+
type: token
128+
tokenSecretKeyRef:
129+
name: my-argocd-token
130+
key: my-token
131+
template: app-proxy/deployment.yaml
132+
asserts:
133+
- contains:
134+
path: spec.template.spec.containers[0].env
135+
content:
136+
name: ARGO_CD_USERNAME
137+
valueFrom:
138+
configMapKeyRef:
139+
key: argoCdUsername
140+
name: cap-app-proxy-cm
141+
142+
- it: app-proxy Deployment should have valid deafult ARGO_CD_PASSWORD env var set via passwordSecretKeyRef with internal argo-cd
143+
values:
144+
- ./values/mandatory-values-ingress.yaml
145+
set:
146+
global:
147+
external-argo-cd:
148+
auth:
149+
type: token
150+
tokenSecretKeyRef:
151+
name: my-argocd-token
152+
key: my-token
153+
template: app-proxy/deployment.yaml
154+
asserts:
155+
- contains:
156+
path: spec.template.spec.containers[0].env
157+
content:
158+
name: ARGO_CD_PASSWORD
159+
valueFrom:
160+
secretKeyRef:
161+
key: password
162+
name: argocd-initial-admin-secret
163+
120164
- it: app-proxy Deployment should have valid ARGO_CD_PASSWORD env var set via passwordSecretKeyRef override
121165
values:
122166
- ./values/mandatory-values-ingress.yaml
@@ -351,6 +395,44 @@ tests:
351395
name: ARGO_CD_TOKEN_SECRET_KEY
352396
value: token
353397

398+
- it: gitops-operator Deployment should have valid default ARGO_CD_TOKEN_SECRET_NAME env var with internal argo-cd
399+
values:
400+
- ./values/mandatory-values-ingress.yaml
401+
set:
402+
global:
403+
external-argo-cd:
404+
auth:
405+
type: token
406+
tokenSecretKeyRef:
407+
name: my-argocd-token
408+
key: my-token
409+
template: gitops-operator/deployment.yaml
410+
asserts:
411+
- contains:
412+
path: spec.template.spec.containers[0].env
413+
content:
414+
name: ARGO_CD_TOKEN_SECRET_NAME
415+
value: argocd-token
416+
417+
- it: gitops-operator Deployment should have valid default ARGO_CD_TOKEN_SECRET_KEY env var with internal argo-cd
418+
values:
419+
- ./values/mandatory-values-ingress.yaml
420+
set:
421+
global:
422+
external-argo-cd:
423+
auth:
424+
type: token
425+
tokenSecretKeyRef:
426+
name: my-argocd-token
427+
key: my-token
428+
template: gitops-operator/deployment.yaml
429+
asserts:
430+
- contains:
431+
path: spec.template.spec.containers[0].env
432+
content:
433+
name: ARGO_CD_TOKEN_SECRET_KEY
434+
value: token
435+
354436
- it: gitops-operator Deployment should have valid ARGO_CD_URL env var
355437
values:
356438
- ./values/mandatory-values-ingress.yaml
@@ -427,6 +509,44 @@ tests:
427509
name: ARGO_CD_TOKEN_SECRET_KEY
428510
value: token
429511

512+
- it: event-reporter StatefulSet should have valid default ARGO_CD_TOKEN_SECRET_NAME env var with internal argo-cd
513+
template: cf-argocd-extras/event-reporter/statefulset.yaml
514+
values:
515+
- ./values/mandatory-values-ingress.yaml
516+
set:
517+
global:
518+
external-argo-cd:
519+
auth:
520+
type: token
521+
tokenSecretKeyRef:
522+
name: my-argocd-token
523+
key: my-token
524+
asserts:
525+
- contains:
526+
path: spec.template.spec.containers[0].env
527+
content:
528+
name: ARGO_CD_TOKEN_SECRET_NAME
529+
value: argocd-token
530+
531+
- it: event-reporter StatefulSet should have valid default ARGO_CD_TOKEN_SECRET_KEY env var
532+
template: cf-argocd-extras/event-reporter/statefulset.yaml
533+
values:
534+
- ./values/mandatory-values-ingress.yaml
535+
set:
536+
global:
537+
external-argo-cd:
538+
auth:
539+
type: token
540+
tokenSecretKeyRef:
541+
name: my-argocd-token
542+
key: my-token
543+
asserts:
544+
- contains:
545+
path: spec.template.spec.containers[0].env
546+
content:
547+
name: ARGO_CD_TOKEN_SECRET_KEY
548+
value: token
549+
430550
- it: event-reporter StatefulSet should have valid ARGO_CD_TOKEN_SECRET_NAME env var set via tokenSecretKeyRef
431551
template: cf-argocd-extras/event-reporter/statefulset.yaml
432552
values:
@@ -557,6 +677,44 @@ tests:
557677
name: ARGO_CD_TOKEN_SECRET_KEY
558678
value: token
559679

680+
- it: sources-server Deployment should have valid default ARGO_CD_TOKEN_SECRET_NAME env var with internal argo-cd
681+
template: cf-argocd-extras/sources-server/deployment.yaml
682+
values:
683+
- ./values/mandatory-values-ingress.yaml
684+
set:
685+
global:
686+
external-argo-cd:
687+
auth:
688+
type: token
689+
tokenSecretKeyRef:
690+
name: my-argocd-token
691+
key: my-token
692+
asserts:
693+
- contains:
694+
path: spec.template.spec.containers[0].env
695+
content:
696+
name: ARGO_CD_TOKEN_SECRET_NAME
697+
value: argocd-token
698+
699+
- it: sources-server Deployment should have valid default ARGO_CD_TOKEN_SECRET_KEY env var with internal argo-cd
700+
template: cf-argocd-extras/sources-server/deployment.yaml
701+
values:
702+
- ./values/mandatory-values-ingress.yaml
703+
set:
704+
global:
705+
external-argo-cd:
706+
auth:
707+
type: token
708+
tokenSecretKeyRef:
709+
name: my-argocd-token
710+
key: my-token
711+
asserts:
712+
- contains:
713+
path: spec.template.spec.containers[0].env
714+
content:
715+
name: ARGO_CD_TOKEN_SECRET_KEY
716+
value: token
717+
560718
- it: sources-server Deployment should have valid ARGO_CD_TOKEN_SECRET_NAME env var set via tokenSecretKeyRef
561719
template: cf-argocd-extras/sources-server/deployment.yaml
562720
values:
@@ -822,3 +980,4 @@ tests:
822980
asserts:
823981
- failedTemplate:
824982
errorMessage: "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set"
983+

0 commit comments

Comments
 (0)