Skip to content

Commit d8a0dea

Browse files
authored
fix: use the rootpath from argo-cd config.params values, when injecting ARGO_CD_URL to gitops-operator (#323)
1 parent bbf49f1 commit d8a0dea

File tree

3 files changed

+66
-22
lines changed

3 files changed

+66
-22
lines changed

charts/gitops-runtime/templates/_helpers.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ Determine argocd server url. Must be called with chart root context
139139
{{- $protocol := "https" }}
140140
{{- $serverName := include "codefresh-gitops-runtime.argocd.server.servicename" . }}
141141
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
142+
{{- $path := (get $argoCDValues.configs.params "server.rootpath") }}
142143
{{- if (eq $port "80") }}
143144
{{- $protocol = "http" }}
144145
{{- end }}
145-
{{- printf "%s://%s:%s" $protocol $serverName $port }}
146+
{{- printf "%s://%s:%s%s" $protocol $serverName $port $path }}
146147
{{- end}}
147148

148149
{{/*

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
{{- $_ := set $gitopsOperatorContext.Values.argoCdNotifications.argocd.repoServer "port" (include "codefresh-gitops-runtime.argocd.reposerver.serviceport" . ) }}
1818

1919
{{/* Set argo-cd-server service and port */}}
20-
{{- $_ := set $gitopsOperatorContext.Values.env "ARGO_CD_URL" (include "codefresh-gitops-runtime.argocd.server.url" . ) }}
20+
{{ if not (index .Values "gitops-operator").env.ARGO_CD_URL }}
21+
{{- $_ := set $gitopsOperatorContext.Values.env "ARGO_CD_URL" (include "codefresh-gitops-runtime.argocd.server.url" . ) }}
22+
{{- end }}
2123

2224
{{/* Set workflows url */}}
2325
{{- if index .Values "argo-workflows" "enabled" }}

charts/gitops-runtime/tests/gitops-controller-misc_test.yaml

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,32 @@ tests:
304304
- contains:
305305
path: spec.template.spec.containers[2].args
306306
content: --argocd-repo-server=myargocd-repo-server:9080
307+
308+
- it: argocd and workflows overrides for manager
309+
template: gitops-operator.yaml
310+
documentSelector:
311+
path: kind
312+
value: Deployment
313+
values:
314+
- ./values/mandatory-values.yaml
315+
set:
316+
argo-cd.configs.params:
317+
server.rootpath: /some-path
318+
argo-cd.fullnameOverride: myargocd
319+
argo-workflows.enabled: true
320+
argo-workflows.fullnameOverride: argo-test
321+
argo-workflows.server.secure: false
322+
asserts:
307323
- contains:
308324
path: spec.template.spec.containers[1].env
309325
content:
310326
name: ARGO_WF_URL
311327
value: http://argo-test-server:2746
328+
- contains:
329+
path: spec.template.spec.containers[1].env
330+
content:
331+
name: ARGO_CD_URL
332+
value: http://myargocd-server:80/some-path
312333

313334
- it: contains all resources for notifications controller
314335
template: gitops-operator.yaml
@@ -318,23 +339,43 @@ tests:
318339
gitops-operator.argoCdNotifications.cm.name: "test-notifications-cm"
319340
gitops-operator.argoCdNotifications.secret.name: "test-notifications-secret"
320341
asserts:
321-
- containsDocument:
322-
kind: ConfigMap
323-
apiVersion: v1
324-
name: test-notifications-cm
325-
any: true
326-
- containsDocument:
327-
kind: Secret
328-
apiVersion: v1
329-
name: test-notifications-secret
330-
any: true
331-
- containsDocument:
332-
kind: ClusterRole
333-
apiVersion: rbac.authorization.k8s.io/v1
334-
name: codefresh-gitops-operator-notifications
335-
any: true
336-
- containsDocument:
337-
kind: ClusterRoleBinding
338-
apiVersion: rbac.authorization.k8s.io/v1
339-
name: codefresh-gitops-operator-notifications
340-
any: true
342+
- containsDocument:
343+
kind: ConfigMap
344+
apiVersion: v1
345+
name: test-notifications-cm
346+
any: true
347+
- containsDocument:
348+
kind: Secret
349+
apiVersion: v1
350+
name: test-notifications-secret
351+
any: true
352+
- containsDocument:
353+
kind: ClusterRole
354+
apiVersion: rbac.authorization.k8s.io/v1
355+
name: codefresh-gitops-operator-notifications
356+
any: true
357+
- containsDocument:
358+
kind: ClusterRoleBinding
359+
apiVersion: rbac.authorization.k8s.io/v1
360+
name: codefresh-gitops-operator-notifications
361+
any: true
362+
363+
- it: uses explicit ARGO_CD_URL instead of value defined by argo-cd settings
364+
template: gitops-operator.yaml
365+
documentSelector:
366+
path: kind
367+
value: Deployment
368+
values:
369+
- ./values/mandatory-values.yaml
370+
set:
371+
argo-cd.configs.params:
372+
server.rootpath: /some-path
373+
argo-cd.fullnameOverride: myargocd
374+
gitops-operator.env.ARGO_CD_URL: http://some-other-url
375+
asserts:
376+
- contains:
377+
path: spec.template.spec.containers[1].env
378+
content:
379+
name: ARGO_CD_URL
380+
value: http://some-other-url
381+

0 commit comments

Comments
 (0)