Skip to content

Commit d935d51

Browse files
feat: external argocd unders .values.global.integrations
1 parent fc5da88 commit d935d51

File tree

4 files changed

+68
-95
lines changed

4 files changed

+68
-95
lines changed

charts/gitops-runtime/templates/_helpers.tpl

Lines changed: 21 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -93,48 +93,28 @@ Determine argocd redis service name. Must be called with chart root context
9393
Determine argocd repo server service name. Must be called with chart root context
9494
*/}}
9595
{{- define "codefresh-gitops-runtime.argocd.reposerver.servicename" -}}
96-
{{/* For now use template from ArgoCD chart until better approach */}}
97-
{{- if (index .Subcharts "argo-cd") }}
98-
{{- template "argo-cd.repoServer.fullname" (dict "Values" (get .Values "argo-cd") "Release" .Release ) }}
99-
{{- else }}
100-
{{- $repoServer := index .Values "global" "external-argo-cd" "repoServer" }}
101-
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.svc }}
102-
{{- printf "%s" $svc }}
103-
{{- end }}
96+
{{- $repoServer := index .Values "global" "integrations" "argo-cd" "repoServer" }}
97+
{{- $svc := required ".Values.global.integrations.argo-cd.repoServer.svc is not set" $repoServer.svc }}
98+
{{- printf "%s" $svc }}
10499
{{- end }}
105100

106101
{{/*
107102
Determine argocd argocd repo server port
108103
*/}}
109104
{{- define "codefresh-gitops-runtime.argocd.reposerver.serviceport" -}}
110-
{{/* For now use template from ArgoCD chart until better approach */}}
111-
{{- if (index .Subcharts "argo-cd") }}
112-
{{- index .Values "argo-cd" "repoServer" "service" "port" }}
113-
{{- else }}
114-
{{- $repoServer := index .Values "global" "external-argo-cd" "repoServer" }}
115-
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.port }}
116-
{{- printf "%v" $port }}
117-
{{- end }}
105+
{{- $repoServer := index .Values "global" "integrations" "argo-cd" "repoServer" }}
106+
{{- $port := required ".Values.global.integrations.argo-cd.repoServer.svc is not set" $repoServer.port }}
107+
{{- printf "%v" $port }}
118108
{{- end }}
119109

120110

121111
{{/*
122112
Determine argocd repoServer url
123113
*/}}
124114
{{- define "codefresh-gitops-runtime.argocd.reposerver.url" -}}
125-
{{- $argoCDValues := (get .Values "argo-cd") }}
126-
{{- if (index .Values "argo-cd" "enabled") }}
127-
{{- $serviceName := include "codefresh-gitops-runtime.argocd.reposerver.servicename" . }}
128-
{{- $port := include "codefresh-gitops-runtime.argocd.reposerver.serviceport" . }}
129-
{{- printf "%s:%s" $serviceName $port }}
130-
{{- else if (index .Values "global" "external-argo-cd" "repoServer") }}
131-
{{- $repoServer := (index .Values "global" "external-argo-cd" "repoServer") }}
132-
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.svc is not set" $repoServer.svc }}
133-
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer.port is not set" $repoServer.port }}
134-
{{- printf "%s:%v" $svc $port }}
135-
{{- else }}
136-
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer is not set" }}
137-
{{- end }}
115+
{{- $repoServer := (index .Values "global" "integrations" "argo-cd" "repoServer") }}
116+
{{- $svc := required ".Values.global.integrations.argo-cd.repoServer.svc is not set" $repoServer.svc }}
117+
{{- $port := required ".Values.global.integrations.argo-cd.repoServer.port is not set" $repoServer.port }}
138118
{{- end}}
139119

140120

@@ -190,49 +170,27 @@ Determine argocd redis service port. Must be called with chart root context
190170
Determine argocd server url. Must be called with chart root context
191171
*/}}
192172
{{- define "codefresh-gitops-runtime.argocd.server.url" -}}
193-
{{- if (index .Values "argo-cd" "enabled") }}
194-
{{- $protocol := "https" }}
195-
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
196-
{{- if (eq $port "80") }}
197-
{{- $protocol = "http" }}
198-
{{- end }}
199-
{{- $url := include "codefresh-gitops-runtime.argocd.server.no-protocol-url" . }}
200-
{{- printf "%s://%s" $protocol $url }}
201-
{{- else if (index .Values "global" "external-argo-cd" "server") }}
202-
{{- $argoCDSrv := (index .Values "global" "external-argo-cd" "server") }}
203-
{{- $protocol := "http" }}
204-
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.svc is not set" $argoCDSrv.svc }}
205-
{{- $port := (required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.port is not port" $argoCDSrv.port) | toString }}
206-
{{- $rootpath := (index .Values "global" "external-argo-cd" "server" "rootpath") }}
207-
{{- if (eq $port "80") }}
208-
{{- printf "%s://%s%s" $protocol $svc $rootpath }}
209-
{{- else }}
210-
{{- printf "%s://%s:%s%s" $protocol $svc $port $rootpath }}
211-
{{- end }}
173+
{{- $argoCDSrv := (index .Values "global" "integrations" "argo-cd" "server") }}
174+
{{- $protocol := "http" }}
175+
{{- $svc := required ".Values.global.integrations.argo-cd.server.svc is not set" $argoCDSrv.svc }}
176+
{{- $port := (required ".Values.global.integrations.argo-cd.server.port is not set" $argoCDSrv.port) | toString }}
177+
{{- $rootpath := (index .Values "global" "integrations" "argo-cd" "server" "rootpath") }}
178+
{{- if (eq $port "80") }}
179+
{{- printf "%s://%s%s" $protocol $svc $rootpath }}
212180
{{- else }}
213-
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set" }}
181+
{{- printf "%s://%s:%s%s" $protocol $svc $port $rootpath }}
214182
{{- end }}
215183
{{- end}}
216184

217185
{{/*
218186
Determine argocd server url witout the protocol. Must be called with chart root context
219187
*/}}
220188
{{- define "codefresh-gitops-runtime.argocd.server.no-protocol-url" -}}
221-
{{- $argoCDValues := (get .Values "argo-cd") }}
222-
{{- if (index .Values "argo-cd" "enabled") }}
223-
{{- $serverName := include "codefresh-gitops-runtime.argocd.server.servicename" . }}
224-
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
225-
{{- $path := (get $argoCDValues.configs.params "server.rootpath") }}
226-
{{- printf "%s:%s%s" $serverName $port $path }}
227-
{{- else if (index .Values "global" "external-argo-cd" "server") }}
228-
{{- $argoCDSrv := (index .Values "global" "external-argo-cd" "server") }}
229-
{{- $svc := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.svc is not set" $argoCDSrv.svc }}
230-
{{- $port := required "ArgoCD is not enabled and .Values.global.external-argo-cd.server.port is not set" $argoCDSrv.port }}
231-
{{- $rootpath := (index .Values "global" "external-argo-cd" "server" "rootpath") }}
189+
{{- $argoCDSrv := (index .Values "global" "integrations" "argo-cd" "server") }}
190+
{{- $svc := required "ArgoCD is not enabled and .Values.global.integrations.argo-cd.server.svc is not set" $argoCDSrv.svc }}
191+
{{- $port := required "ArgoCD is not enabled and .Values.global.integrations.argo-cd.server.port is not set" $argoCDSrv.port }}
192+
{{- $rootpath := (index .Values "global" "integrations" "argo-cd" "server" "rootpath") }}
232193
{{- printf "%s:%v%s" $svc $port $rootpath }}
233-
{{- else }}
234-
{{- fail "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set" }}
235-
{{- end }}
236194
{{- end}}
237195

238196
{{- define "codefresh-gitops-runtime.argocd-auth" -}}

charts/gitops-runtime/tests/external_argocd_test.yaml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,12 @@ tests:
681681
- ./values/external-argocd-values.yaml
682682
set:
683683
global:
684-
external-argo-cd:
685-
repoServer: null
684+
integrations:
685+
argo-cd:
686+
repoServer: null
686687
asserts:
687688
- failedTemplate:
688-
errorMessage: "ArgoCD is not enabled and .Values.global.external-argo-cd.repoServer is not set"
689+
errorMessage: ".Values.global.integrations.argo-cd.repoServer is not set"
689690

690691
- it: should required only allowed auth type for external ArgoCd
691692
values:
@@ -709,9 +710,10 @@ tests:
709710
- ./values/external-argocd-values.yaml
710711
set:
711712
global:
712-
external-argo-cd:
713-
server:
714-
rootpath: /argocd
713+
integrations:
714+
argo-cd:
715+
server:
716+
rootpath: /argocd
715717
asserts:
716718
- contains:
717719
path: spec.template.spec.containers[0].env
@@ -726,9 +728,10 @@ tests:
726728
- ./values/external-argocd-values.yaml
727729
set:
728730
global:
729-
external-argo-cd:
730-
server:
731-
rootpath: /argocd
731+
integrations:
732+
argo-cd:
733+
server:
734+
rootpath: /argocd
732735
asserts:
733736
- contains:
734737
path: spec.template.spec.containers[0].env
@@ -743,9 +746,10 @@ tests:
743746
template: app-proxy/config.yaml
744747
set:
745748
global:
746-
external-argo-cd:
747-
server:
748-
rootpath: /argocd
749+
integrations:
750+
argo-cd:
751+
server:
752+
rootpath: /argocd
749753
asserts:
750754
- equal:
751755
path: data.argoCdUrl
@@ -758,9 +762,10 @@ tests:
758762
- ./values/external-argocd-values.yaml
759763
set:
760764
global:
761-
external-argo-cd:
762-
server:
763-
rootpath: /argocd
765+
integrations:
766+
argo-cd:
767+
server:
768+
rootpath: /argocd
764769
asserts:
765770
- contains:
766771
path: spec.template.spec.containers[0].env
@@ -850,8 +855,9 @@ tests:
850855
- ./values/external-argocd-values.yaml
851856
set:
852857
global:
853-
external-argo-cd:
854-
server: null
858+
integrations:
859+
argo-cd:
860+
server: null
855861
asserts:
856862
- failedTemplate:
857-
errorMessage: "ArgoCD is not enabled and .Values.global.external-argo-cd.server is not set"
863+
errorMessage: "ArgoCD is not enabled and .Values.global.integrations.argo-cd.server is not set"
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
global:
2-
external-argo-cd:
3-
server:
4-
protocol: http
5-
svc: my-argocd-server
6-
port: 80
7-
image:
8-
repository: quay.io/argoproj/argocd
9-
tag: v2.14.2
10-
redis:
11-
svc: my-argocd-redis
12-
port: 6379
13-
repoServer:
14-
svc: my-argocd-repo-server
15-
port: 8081
2+
integrations:
3+
argo-cd:
4+
server:
5+
protocol: http
6+
svc: my-argocd-server
7+
port: 80
8+
repoServer:
9+
svc: my-argocd-repo-server
10+
port: 8081
1611

1712
argo-cd:
1813
enabled: false

charts/gitops-runtime/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ global:
103103
# tokenSecretKeyRef:
104104
# name: argocd-token
105105
# key: token
106+
# -- Service name of the ArgoCD server
107+
svc: argo-cd-server
108+
# -- Port of the ArgoCD server
109+
port: 80
110+
# -- Set if Argo CD is running behind reverse proxy under subpath different from /
111+
# e.g.
112+
# rootpath: '/argocd'
113+
rootpath: ''
114+
repoServer:
115+
# -- Service name of the ArgoCD repo server
116+
svc: argo-cd-repo-server
117+
# -- Port of the ArgoCD repo server
118+
port: 8081
119+
106120
# -- Configuration for external ArgoCD
107121
# Should be used when `argo-cd.enabled` is set to false
108122
external-argo-cd:

0 commit comments

Comments
 (0)