Skip to content

Commit

Permalink
Merge pull request #545 from MusicDin/fix/url-port
Browse files Browse the repository at this point in the history
provider-config: Append port to hostname instead of the URL
  • Loading branch information
simondeziel authored Nov 29, 2024
2 parents 60db667 + 8233727 commit c9abd17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/provider-config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ func DetermineLXDAddress(protocol string, address string) (string, error) {
port = "443"
}

address = fmt.Sprintf("%s:%s", address, port)
url.Host = fmt.Sprintf("%s:%s", url.Hostname(), port)
}

return address, nil
return url.String(), nil
default:
return "", fmt.Errorf("Invalid scheme %q: Value must be one of: [unix, https]", scheme)
}
Expand Down
12 changes: 12 additions & 0 deletions internal/provider-config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ func TestDetermineLXDAddress(t *testing.T) {
Address: "https://localhost:1234",
Expect: "https://localhost:1234",
},
{
Name: "Scheme, hostname, port | URL path",
Protocol: "simplestreams",
Address: "https://example.com/cloud-images/releases",
Expect: "https://example.com:443/cloud-images/releases",
},
{
Name: "Scheme, hostname, port | URL path with preconfigured port",
Protocol: "simplestreams",
Address: "https://example.com:1234/cloud-images/releases",
Expect: "https://example.com:1234/cloud-images/releases",
},
// Expected errors.
{
Name: "Unsupported simplestreams scheme",
Expand Down

0 comments on commit c9abd17

Please sign in to comment.