From 5428bf5528e414a3f053ffe620efbaead0301cf6 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 2 Apr 2021 16:51:49 -0500 Subject: [PATCH] [HCS-1831] Remove extraneous protocol from fqdn string if present --- .../data_source_consul_agent_helm_config.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/provider/data_source_consul_agent_helm_config.go b/internal/provider/data_source_consul_agent_helm_config.go index 1abe2fe39..2a8e014a3 100644 --- a/internal/provider/data_source_consul_agent_helm_config.go +++ b/internal/provider/data_source_consul_agent_helm_config.go @@ -190,6 +190,19 @@ func generateHelmConfig(name, datacenter, fqdn string, retryJoin []string, expos // replace any escaped double-quotes with single quotes rj = strings.Replace(rj, "\"", "'", -1) + // trim off any leading `https://` protocol if present. + // this protocol will be prepended as expected when + // the helm config string is generated. + // + // this string is trimmed here to handle both the cases + // of when the provided fqdn string has the leading + // protocol and does not. + // + // trimming the leading protocol here will guarantee a + // valid URL is generated when prepended in the + // helmConfigTemplate. + fqdn = strings.TrimPrefix(fqdn, "https://") + return fmt.Sprintf(helmConfigTemplate, datacenter, lower, lower, lower,