registry: renaming module-specific registry functions

pull/18625/head
Kristin Laemmert 8 years ago
parent 57f99389e8
commit f2c460cb2f

@ -316,7 +316,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
}
@ -336,7 +336,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, 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{

@ -77,8 +77,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
@ -153,9 +153,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")
}
}
@ -86,22 +86,22 @@ func TestRegistryAuth(t *testing.T) {
}
// both should fail without auth
_, err = client.Versions(mod)
_, err = client.ModuleVersions(mod)
if err == nil {
t.Fatal("expected error")
}
_, err = client.Location(mod, "1.0.0")
_, err = client.ModuleLocation(mod, "1.0.0")
if err == nil {
t.Fatal("expected error")
}
client = NewClient(test.Disco(server), test.Credentials, nil)
_, err = client.Versions(mod)
_, err = client.ModuleVersions(mod)
if err != nil {
t.Fatal(err)
}
_, err = client.Location(mod, "1.0.0")
_, err = client.ModuleLocation(mod, "1.0.0")
if err != nil {
t.Fatal(err)
}
@ -119,7 +119,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)
}
@ -147,7 +147,7 @@ func TestAccLookupModuleVersions(t *testing.T) {
}
s := NewClient(regDisco, nil, nil)
resp, err := s.Versions(modsrc)
resp, err := s.ModuleVersions(modsrc)
if err != nil {
t.Fatal(err)
}
@ -189,7 +189,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")
}

Loading…
Cancel
Save