Skip to content
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

[HCS-1831] Remove extraneous protocol from fqdn string if present #95

Merged
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
13 changes: 13 additions & 0 deletions internal/provider/data_source_consul_agent_helm_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down