registry: renaming module-specific registry functions
This commit is contained in:
parent
082af84131
commit
d1f27ce8c2
|
@ -312,7 +312,7 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e
|
|||
// we need to lookup available versions
|
||||
// Only on Get if it's not found, on unconditionally on Update
|
||||
if (s.Mode == GetModeGet && !found) || (s.Mode == GetModeUpdate) {
|
||||
resp, err := s.registry.Versions(mod)
|
||||
resp, err := s.registry.ModuleVersions(mod)
|
||||
if err != nil {
|
||||
return rec, err
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e
|
|||
|
||||
rec.Version = match.Version
|
||||
|
||||
rec.url, err = s.registry.Location(mod, rec.Version)
|
||||
rec.url, err = s.registry.ModuleLocation(mod, rec.Version)
|
||||
if err != nil {
|
||||
return rec, err
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func TestAccRegistryDiscover(t *testing.T) {
|
|||
}
|
||||
|
||||
s := NewStorage("/tmp", nil)
|
||||
loc, err := s.registry.Location(module, "")
|
||||
loc, err := s.registry.ModuleLocation(module, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ func (l *Loader) installRegistryModule(req *configs.ModuleRequest, key string, i
|
|||
reg := l.modules.Registry
|
||||
|
||||
log.Printf("[DEBUG] %s listing available versions of %s at %s", key, addr, hostname)
|
||||
resp, err := reg.Versions(addr)
|
||||
resp, err := reg.ModuleVersions(addr)
|
||||
if err != nil {
|
||||
if registry.IsModuleNotFound(err) {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
|
@ -393,7 +393,7 @@ func (l *Loader) installRegistryModule(req *configs.ModuleRequest, key string, i
|
|||
// If we manage to get down here then we've found a suitable version to
|
||||
// install, so we need to ask the registry where we should download it from.
|
||||
// The response to this is a go-getter-style address string.
|
||||
dlAddr, err := reg.Location(addr, latestMatch.String())
|
||||
dlAddr, err := reg.ModuleLocation(addr, latestMatch.String())
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %s from %s %s: %s", key, addr, latestMatch, err)
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
|
|
|
@ -70,8 +70,8 @@ func (c *Client) Discover(host svchost.Hostname, serviceID string) *url.URL {
|
|||
return service
|
||||
}
|
||||
|
||||
// Versions queries the registry for a module, and returns the available versions.
|
||||
func (c *Client) Versions(module *regsrc.Module) (*response.ModuleVersions, error) {
|
||||
// ModuleVersions queries the registry for a module, and returns the available versions.
|
||||
func (c *Client) ModuleVersions(module *regsrc.Module) (*response.ModuleVersions, error) {
|
||||
host, err := module.SvcHost()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -142,9 +142,9 @@ func (c *Client) addRequestCreds(host svchost.Hostname, req *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// Location find the download location for a specific version module.
|
||||
// ModuleLocation find the download location for a specific version module.
|
||||
// This returns a string, because the final location may contain special go-getter syntax.
|
||||
func (c *Client) Location(module *regsrc.Module, version string) (string, error) {
|
||||
func (c *Client) ModuleLocation(module *regsrc.Module, version string) (string, error) {
|
||||
host, err := module.SvcHost()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestLookupModuleVersions(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := client.Versions(modsrc)
|
||||
resp, err := client.ModuleVersions(modsrc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func TestInvalidRegistry(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := client.Versions(modsrc); err == nil {
|
||||
if _, err := client.ModuleVersions(modsrc); err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
}
|
||||
|
@ -85,26 +85,26 @@ func TestRegistryAuth(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = client.Versions(mod)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
// both should fail without auth
|
||||
_, err = client.ModuleVersions(mod)
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
_, err = client.Location(mod, "1.0.0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
_, err = client.ModuleLocation(mod, "1.0.0")
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
|
||||
// Also test without a credentials source
|
||||
client.services.SetCredentialsSource(nil)
|
||||
|
||||
// both should fail without auth
|
||||
_, err = client.Versions(mod)
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
_, err = client.ModuleVersions(mod)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = client.Location(mod, "1.0.0")
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
_, err = client.ModuleLocation(mod, "1.0.0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ func TestLookupModuleLocationRelative(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
got, err := client.Location(mod, "0.2.0")
|
||||
got, err := client.ModuleLocation(mod, "0.2.0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func TestAccLookupModuleVersions(t *testing.T) {
|
|||
}
|
||||
|
||||
s := NewClient(regDisco, nil)
|
||||
resp, err := s.Versions(modsrc)
|
||||
resp, err := s.ModuleVersions(modsrc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func TestLookupLookupModuleError(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = client.Location(mod, "0.2.0")
|
||||
_, err = client.ModuleLocation(mod, "0.2.0")
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ func TestLookupProviderVersions(t *testing.T) {
|
|||
server := test.Registry()
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(test.Disco(server), nil, nil)
|
||||
client := NewClient(test.Disco(server), nil)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -242,7 +242,7 @@ func TestLookupProviderLocation(t *testing.T) {
|
|||
server := test.Registry()
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(test.Disco(server), nil, nil)
|
||||
client := NewClient(test.Disco(server), nil)
|
||||
|
||||
tests := []struct {
|
||||
Name string
|
||||
|
|
Loading…
Reference in New Issue