From 55d62b58ba37c4ee8c1ffdb7e0695fef7c953d89 Mon Sep 17 00:00:00 2001 From: Umut Sahin Date: Fri, 21 Jul 2023 18:51:34 +0300 Subject: [PATCH] Fixed issue with oci repo url having port --- pkg/apis/application/v1alpha1/repository_types.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/apis/application/v1alpha1/repository_types.go b/pkg/apis/application/v1alpha1/repository_types.go index 31e8c47971414..ca4b35633ca10 100644 --- a/pkg/apis/application/v1alpha1/repository_types.go +++ b/pkg/apis/application/v1alpha1/repository_types.go @@ -2,6 +2,7 @@ package v1alpha1 import ( "fmt" + "net" "net/url" "github.com/argoproj/argo-cd/v2/util/cert" @@ -243,8 +244,15 @@ func getCAPath(repoURL string) string { } if hostname == "" { - log.Warnf("Could not get hostname for repository '%s'", repoURL) - return "" + hostname, _, err = net.SplitHostPort(repoURL) + if err != nil { + log.Warnf("Could not parse repo URL '%s': %v", repoURL, err) + return "" + } + if hostname == "" { + log.Warnf("Could not get hostname for repository '%s'", repoURL) + return "" + } } caPath, err := cert.GetCertBundlePathForRepository(hostname)