From 6c20141c30e06e817325f1b4280631dace894fcb Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 6 Sep 2017 12:57:15 -0400 Subject: [PATCH] remove subdir handling from Tree.Load Terraform was redundantly handling `//dir` notation which should be handled by go-getter. Rather than allowing go-getter to unpack a subdir as expected, the subdir was stripped off and accessed through the module configuration. This scheme will no longer works now that go-getter supports `*` subdirectories (e.g. `//*` would be analogous to `tar --strip-components=1`). Even though this allows Terraform to use go-getter's native unpacking, detection is still done separately because Detect requires a `pwd` which is dependent on the configuration directory and not known to the global FolderStorage. --- config/module/tree.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/config/module/tree.go b/config/module/tree.go index 4ac0b11fb4..f50da2d6d2 100644 --- a/config/module/tree.go +++ b/config/module/tree.go @@ -4,7 +4,6 @@ import ( "bufio" "bytes" "fmt" - "path/filepath" "strings" "sync" @@ -177,23 +176,14 @@ func (t *Tree) Load(s getter.Storage, mode GetMode) error { copy(path, t.path) path = append(path, m.Name) - // Split out the subdir if we have one - source, subDir := getter.SourceDirSubdir(m.Source) - - source, err := getter.Detect(source, t.config.Dir, detectors) + source, err := getter.Detect(m.Source, t.config.Dir, detectors) if err != nil { return fmt.Errorf("module %s: %s", m.Name, err) } - - // Check if the detector introduced something new. - source, subDir2 := getter.SourceDirSubdir(source) - if subDir2 != "" { - subDir = filepath.Join(subDir2, subDir) - } - // Get the directory where this module is so we can load it key := strings.Join(path, ".") key = fmt.Sprintf("root.%s-%s", key, m.Source) + dir, ok, err := getStorage(s, key, source, mode) if err != nil { return err @@ -203,12 +193,6 @@ func (t *Tree) Load(s getter.Storage, mode GetMode) error { "module %s: not found, may need to be downloaded using 'terraform get'", m.Name) } - // If we have a subdirectory, then merge that in - if subDir != "" { - dir = filepath.Join(dir, subDir) - } - - // Load the configurations.Dir(source) children[m.Name], err = NewTreeModule(m.Name, dir) if err != nil { return fmt.Errorf(