From 65d3b8ce434a8399e853400e28af27b336842ccf Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Tue, 28 May 2024 12:25:15 +0200 Subject: [PATCH] Check if URL already contains remote write path before appending it Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- .../controllers/placementrule/hub_info_secret.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/operators/multiclusterobservability/controllers/placementrule/hub_info_secret.go b/operators/multiclusterobservability/controllers/placementrule/hub_info_secret.go index a32a1bccf..502ec60fa 100644 --- a/operators/multiclusterobservability/controllers/placementrule/hub_info_secret.go +++ b/operators/multiclusterobservability/controllers/placementrule/hub_info_secret.go @@ -69,9 +69,13 @@ func generateHubInfoSecret(client client.Client, obsNamespace string, } } - obsApiURL := url.URL{ - Host: obsAPIHost, - Path: operatorconfig.ObservatoriumAPIRemoteWritePath, + if !strings.HasSuffix(obsAPIHost, operatorconfig.ObservatoriumAPIRemoteWritePath) { + obsAPIHost += operatorconfig.ObservatoriumAPIRemoteWritePath + } + + obsApiURL, err := url.Parse(obsAPIHost) + if err != nil { + return nil, err } if !obsApiURL.IsAbs() { obsApiURL.Scheme = "https"