From f64851242e84333959c5cb1a33ec0d62f70e9479 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 27 Oct 2017 19:27:20 -0400 Subject: [PATCH] use Storage.GetModule for init -from-module This will enable copying any module source into a target directory. --- command/init.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/command/init.go b/command/init.go index 28e4ffbbb..03e7df9ca 100644 --- a/command/init.go +++ b/command/init.go @@ -9,8 +9,6 @@ import ( "github.com/posener/complete" - "github.com/hashicorp/go-getter" - multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/config" @@ -131,7 +129,8 @@ func (c *InitCommand) Run(args []string) int { ))) header = true - if err := c.copyConfigFromModule(path, src, pwd); err != nil { + s := module.NewStorage("", c.Services, c.Credentials) + if err := s.GetModule(path, src); err != nil { c.Ui.Error(fmt.Sprintf("Error copying source module: %s", err)) return 1 } @@ -272,19 +271,6 @@ func (c *InitCommand) Run(args []string) int { return 0 } -func (c *InitCommand) copyConfigFromModule(dst, src, pwd string) error { - // errors from this function will be prefixed with "Error copying source module: " - // when returned to the user. - var err error - - src, err = getter.Detect(src, pwd, getter.Detectors) - if err != nil { - return fmt.Errorf("invalid module source: %s", err) - } - - return module.GetCopy(dst, src) -} - // Load the complete module tree, and fetch any missing providers. // This method outputs its own Ui. func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade bool) error {