Skip to content

fix: don't use protocol for ARGO_CD_URL in gitops-operator #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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