Skip to content

Commit

Permalink
fix: don't use protocol for ARGO_CD_URL in gitops-operator (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATGardner committed Nov 7, 2024
1 parent 2b3386c commit 0e0f0c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 13 additions & 4 deletions charts/gitops-runtime/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,24 @@ Determine argocd server service port. Must be called with chart root context
Determine argocd server url. Must be called with chart root context
*/}}
{{- define "codefresh-gitops-runtime.argocd.server.url" -}}
{{- $argoCDValues := (get .Values "argo-cd") }}
{{- $protocol := "https" }}
{{- $serverName := include "codefresh-gitops-runtime.argocd.server.servicename" . }}
{{- $port := include "codefresh-gitops-runtime.argocd.server.serviceport" . }}
{{- $path := (get $argoCDValues.configs.params "server.rootpath") }}
{{- if (eq $port "80") }}
{{- $protocol = "http" }}
{{- end }}
{{- printf "%s://%s:%s%s" $protocol $serverName $port $path }}
{{- $url := include "codefresh-gitops-runtime.argocd.server.no-protocol-url" . }}
{{- printf "%s://%s" $protocol $url }}
{{- 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") }}
{{- $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 }}
{{- end}}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion charts/gitops-runtime/templates/gitops-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

{{/* Set workflows url */}}
Expand Down
6 changes: 3 additions & 3 deletions charts/gitops-runtime/tests/gitops-controller-misc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ tests:
path: spec.template.spec.containers[1].env
content:
name: ARGO_CD_URL
value: http://myargocd-server:80/some-path
value: myargocd-server:80/some-path

- it: contains all resources for notifications controller
template: gitops-operator.yaml
Expand Down Expand Up @@ -371,11 +371,11 @@ tests:
argo-cd.configs.params:
server.rootpath: /some-path
argo-cd.fullnameOverride: myargocd
gitops-operator.env.ARGO_CD_URL: http://some-other-url
gitops-operator.env.ARGO_CD_URL: some-other-url:123
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: ARGO_CD_URL
value: http://some-other-url
value: some-other-url:123

0 comments on commit 0e0f0c8

Please sign in to comment.