Merge pull request #17134 from hashicorp/jbardin/GH-17119
the trailing slash check caused a nil dereference
This commit is contained in:
commit
eba73a3bb4
|
@ -67,6 +67,9 @@ func NewClient(services *disco.Disco, creds auth.CredentialsSource, client *http
|
||||||
// Discover qeuries the host, and returns the url for the registry.
|
// Discover qeuries the host, and returns the url for the registry.
|
||||||
func (c *Client) Discover(host svchost.Hostname) *url.URL {
|
func (c *Client) Discover(host svchost.Hostname) *url.URL {
|
||||||
service := c.services.DiscoverServiceURL(host, serviceID)
|
service := c.services.DiscoverServiceURL(host, serviceID)
|
||||||
|
if service == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if !strings.HasSuffix(service.Path, "/") {
|
if !strings.HasSuffix(service.Path, "/") {
|
||||||
service.Path += "/"
|
service.Path += "/"
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,23 @@ func TestLookupModuleVersions(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInvalidRegistry(t *testing.T) {
|
||||||
|
server := test.Registry()
|
||||||
|
defer server.Close()
|
||||||
|
|
||||||
|
client := NewClient(test.Disco(server), nil, nil)
|
||||||
|
|
||||||
|
src := "non-existent.localhost.localdomain/test-versions/name/provider"
|
||||||
|
modsrc, err := regsrc.ParseModuleSource(src)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := client.Versions(modsrc); err == nil {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRegistryAuth(t *testing.T) {
|
func TestRegistryAuth(t *testing.T) {
|
||||||
server := test.Registry()
|
server := test.Registry()
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
Loading…
Reference in New Issue