diff --git a/command/command_test.go b/command/command_test.go index 598805a2c..e867ae45d 100644 --- a/command/command_test.go +++ b/command/command_test.go @@ -19,7 +19,6 @@ import ( "syscall" "testing" - "github.com/hashicorp/go-getter" "github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/terraform" @@ -108,8 +107,11 @@ func testModule(t *testing.T, name string) *module.Tree { t.Fatalf("err: %s", err) } - s := &getter.FolderStorage{StorageDir: tempDir(t)} - if err := mod.Load(s, module.GetModeGet); err != nil { + s := &module.ModuleStorage{ + StorageDir: tempDir(t), + Mode: module.GetModeGet, + } + if err := mod.Load(s); err != nil { t.Fatalf("err: %s", err) } diff --git a/command/get.go b/command/get.go index d51ae39b3..ba8729d79 100644 --- a/command/get.go +++ b/command/get.go @@ -81,7 +81,7 @@ func getModules(m *Meta, path string, mode module.GetMode) error { return fmt.Errorf("Error loading configuration: %s", err) } - err = mod.Load(m.moduleStorage(m.DataDir()), mode) + err = mod.Load(m.moduleStorage(m.DataDir(), mode)) if err != nil { return fmt.Errorf("Error loading modules: %s", err) } diff --git a/command/meta.go b/command/meta.go index bb58ab654..24493116e 100644 --- a/command/meta.go +++ b/command/meta.go @@ -16,11 +16,11 @@ import ( "strings" "time" - "github.com/hashicorp/go-getter" "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/backend/local" "github.com/hashicorp/terraform/command/format" "github.com/hashicorp/terraform/config" + "github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/helper/experiment" "github.com/hashicorp/terraform/helper/variables" "github.com/hashicorp/terraform/helper/wrappedstreams" @@ -368,12 +368,12 @@ func (m *Meta) flagSet(n string) *flag.FlagSet { // moduleStorage returns the module.Storage implementation used to store // modules for commands. -func (m *Meta) moduleStorage(root string) getter.Storage { - return &uiModuleStorage{ - Storage: &getter.FolderStorage{ - StorageDir: filepath.Join(root, "modules"), - }, - Ui: m.Ui, +func (m *Meta) moduleStorage(root string, mode module.GetMode) *module.ModuleStorage { + return &module.ModuleStorage{ + StorageDir: filepath.Join(root, "modules"), + Services: m.Services, + Ui: m.Ui, + Mode: mode, } } diff --git a/command/meta_new.go b/command/meta_new.go index 9447caf3b..5fc3cdca3 100644 --- a/command/meta_new.go +++ b/command/meta_new.go @@ -45,7 +45,7 @@ func (m *Meta) Module(path string) (*module.Tree, error) { return nil, err } - err = mod.Load(m.moduleStorage(m.DataDir()), module.GetModeNone) + err = mod.Load(m.moduleStorage(m.DataDir(), module.GetModeNone)) if err != nil { return nil, errwrap.Wrapf("Error loading modules: {{err}}", err) } diff --git a/command/module_storage.go b/command/module_storage.go deleted file mode 100644 index 5bb832897..000000000 --- a/command/module_storage.go +++ /dev/null @@ -1,29 +0,0 @@ -package command - -import ( - "fmt" - - "github.com/hashicorp/go-getter" - "github.com/mitchellh/cli" -) - -// uiModuleStorage implements module.Storage and is just a proxy to output -// to the UI any Get operations. -type uiModuleStorage struct { - Storage getter.Storage - Ui cli.Ui -} - -func (s *uiModuleStorage) Dir(key string) (string, bool, error) { - return s.Storage.Dir(key) -} - -func (s *uiModuleStorage) Get(key string, source string, update bool) error { - updateStr := "" - if update { - updateStr = " (update)" - } - - s.Ui.Output(fmt.Sprintf("Get: %s%s", source, updateStr)) - return s.Storage.Get(key, source, update) -} diff --git a/command/module_storage_test.go b/command/module_storage_test.go deleted file mode 100644 index 97a5ed7ae..000000000 --- a/command/module_storage_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package command - -import ( - "testing" - - "github.com/hashicorp/go-getter" -) - -func TestUiModuleStorage_impl(t *testing.T) { - var _ getter.Storage = new(uiModuleStorage) -} diff --git a/config/module/storage.go b/config/module/storage.go index f4cf2bd0f..9280ce9ae 100644 --- a/config/module/storage.go +++ b/config/module/storage.go @@ -190,6 +190,14 @@ func (m ModuleStorage) getStorage(key string, src string) (string, bool, error) StorageDir: m.StorageDir, } + if m.Ui != nil { + update := "" + if m.Mode == GetModeUpdate { + update = " (update)" + } + m.Ui.Output(fmt.Sprintf("Get: %s%s", src, update)) + } + // Get the module with the level specified if we were told to. if m.Mode > GetModeNone { log.Printf("[DEBUG] fetching %q with key %q", src, key) diff --git a/helper/resource/testing.go b/helper/resource/testing.go index aa0aa51fb..20fc0145b 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -15,7 +15,6 @@ import ( "testing" "github.com/davecgh/go-spew/spew" - "github.com/hashicorp/go-getter" "github.com/hashicorp/go-multierror" "github.com/hashicorp/logutils" "github.com/hashicorp/terraform/config/module" @@ -751,10 +750,11 @@ func testModule( } // Load the modules - modStorage := &getter.FolderStorage{ + modStorage := &module.ModuleStorage{ StorageDir: filepath.Join(cfgPath, ".tfmodules"), + Mode: module.GetModeGet, } - err = mod.Load(modStorage, module.GetModeGet) + err = mod.Load(modStorage) if err != nil { return nil, fmt.Errorf("Error downloading modules: %s", err) }