From 0e0f0c8c2311134753fc92c1f462a37c774cc123 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Thu, 7 Nov 2024 19:01:11 +0200 Subject: [PATCH] fix: don't use protocol for ARGO_CD_URL in gitops-operator (#332) --- charts/gitops-runtime/templates/_helpers.tpl | 17 +++++++++++++---- .../templates/gitops-operator.yaml | 2 +- .../tests/gitops-controller-misc_test.yaml | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/charts/gitops-runtime/templates/_helpers.tpl b/charts/gitops-runtime/templates/_helpers.tpl index 82219aed..d47df549 100644 --- a/charts/gitops-runtime/templates/_helpers.tpl +++ b/charts/gitops-runtime/templates/_helpers.tpl @@ -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}} {{/* diff --git a/charts/gitops-runtime/templates/gitops-operator.yaml b/charts/gitops-runtime/templates/gitops-operator.yaml index 500d7107..95de6f96 100644 --- a/charts/gitops-runtime/templates/gitops-operator.yaml +++ b/charts/gitops-runtime/templates/gitops-operator.yaml @@ -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 */}} diff --git a/charts/gitops-runtime/tests/gitops-controller-misc_test.yaml b/charts/gitops-runtime/tests/gitops-controller-misc_test.yaml index e3d1ea42..1a0dd999 100644 --- a/charts/gitops-runtime/tests/gitops-controller-misc_test.yaml +++ b/charts/gitops-runtime/tests/gitops-controller-misc_test.yaml @@ -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 @@ -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