registry: renaming module-specific registry functions

This commit is contained in:
Kristin Laemmert 2018-07-30 15:44:06 -07:00 committed by Martin Atkins
parent 082af84131
commit d1f27ce8c2
5 changed files with 29 additions and 29 deletions

View File

@ -312,7 +312,7 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e
// we need to lookup available versions // we need to lookup available versions
// Only on Get if it's not found, on unconditionally on Update // Only on Get if it's not found, on unconditionally on Update
if (s.Mode == GetModeGet && !found) || (s.Mode == GetModeUpdate) { if (s.Mode == GetModeGet && !found) || (s.Mode == GetModeUpdate) {
resp, err := s.registry.Versions(mod) resp, err := s.registry.ModuleVersions(mod)
if err != nil { if err != nil {
return rec, err return rec, err
} }
@ -332,7 +332,7 @@ func (s Storage) findRegistryModule(mSource, constraint string) (moduleRecord, e
rec.Version = match.Version 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 { if err != nil {
return rec, err return rec, err
} }

View File

@ -140,7 +140,7 @@ func TestAccRegistryDiscover(t *testing.T) {
} }
s := NewStorage("/tmp", nil) s := NewStorage("/tmp", nil)
loc, err := s.registry.Location(module, "") loc, err := s.registry.ModuleLocation(module, "")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -293,7 +293,7 @@ func (l *Loader) installRegistryModule(req *configs.ModuleRequest, key string, i
reg := l.modules.Registry reg := l.modules.Registry
log.Printf("[DEBUG] %s listing available versions of %s at %s", key, addr, hostname) 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 err != nil {
if registry.IsModuleNotFound(err) { if registry.IsModuleNotFound(err) {
diags = append(diags, &hcl.Diagnostic{ 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 // 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. // 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. // 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 { if err != nil {
log.Printf("[ERROR] %s from %s %s: %s", key, addr, latestMatch, err) log.Printf("[ERROR] %s from %s %s: %s", key, addr, latestMatch, err)
diags = append(diags, &hcl.Diagnostic{ diags = append(diags, &hcl.Diagnostic{

View File

@ -70,8 +70,8 @@ func (c *Client) Discover(host svchost.Hostname, serviceID string) *url.URL {
return service return service
} }
// Versions queries the registry for a module, and returns the available versions. // ModuleVersions queries the registry for a module, and returns the available versions.
func (c *Client) Versions(module *regsrc.Module) (*response.ModuleVersions, error) { func (c *Client) ModuleVersions(module *regsrc.Module) (*response.ModuleVersions, error) {
host, err := module.SvcHost() host, err := module.SvcHost()
if err != nil { if err != nil {
return nil, err 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. // 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() host, err := module.SvcHost()
if err != nil { if err != nil {
return "", err return "", err

View File

@ -28,7 +28,7 @@ func TestLookupModuleVersions(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
resp, err := client.Versions(modsrc) resp, err := client.ModuleVersions(modsrc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -68,7 +68,7 @@ func TestInvalidRegistry(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if _, err := client.Versions(modsrc); err == nil { if _, err := client.ModuleVersions(modsrc); err == nil {
t.Fatal("expected error") t.Fatal("expected error")
} }
} }
@ -85,26 +85,26 @@ func TestRegistryAuth(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
_, err = client.Versions(mod) // both should fail without auth
if err != nil { _, err = client.ModuleVersions(mod)
t.Fatal(err) if err == nil {
t.Fatal("expected error")
} }
_, err = client.Location(mod, "1.0.0") _, err = client.ModuleLocation(mod, "1.0.0")
if err != nil { if err == nil {
t.Fatal(err) t.Fatal("expected error")
} }
// Also test without a credentials source // Also test without a credentials source
client.services.SetCredentialsSource(nil) client.services.SetCredentialsSource(nil)
// both should fail without auth _, err = client.ModuleVersions(mod)
_, err = client.Versions(mod) if err != nil {
if err == nil { t.Fatal(err)
t.Fatal("expected error")
} }
_, err = client.Location(mod, "1.0.0") _, err = client.ModuleLocation(mod, "1.0.0")
if err == nil { if err != nil {
t.Fatal("expected error") t.Fatal(err)
} }
} }
@ -120,7 +120,7 @@ func TestLookupModuleLocationRelative(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
got, err := client.Location(mod, "0.2.0") got, err := client.ModuleLocation(mod, "0.2.0")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -148,7 +148,7 @@ func TestAccLookupModuleVersions(t *testing.T) {
} }
s := NewClient(regDisco, nil) s := NewClient(regDisco, nil)
resp, err := s.Versions(modsrc) resp, err := s.ModuleVersions(modsrc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -190,7 +190,7 @@ func TestLookupLookupModuleError(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
_, err = client.Location(mod, "0.2.0") _, err = client.ModuleLocation(mod, "0.2.0")
if err == nil { if err == nil {
t.Fatal("expected error") t.Fatal("expected error")
} }
@ -205,7 +205,7 @@ func TestLookupProviderVersions(t *testing.T) {
server := test.Registry() server := test.Registry()
defer server.Close() defer server.Close()
client := NewClient(test.Disco(server), nil, nil) client := NewClient(test.Disco(server), nil)
tests := []struct { tests := []struct {
name string name string
@ -242,7 +242,7 @@ func TestLookupProviderLocation(t *testing.T) {
server := test.Registry() server := test.Registry()
defer server.Close() defer server.Close()
client := NewClient(test.Disco(server), nil, nil) client := NewClient(test.Disco(server), nil)
tests := []struct { tests := []struct {
Name string Name string