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.
This commit is contained in:
parent
a83ff57aea
commit
6c20141c30
|
@ -4,7 +4,6 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -177,23 +176,14 @@ func (t *Tree) Load(s getter.Storage, mode GetMode) error {
|
||||||
copy(path, t.path)
|
copy(path, t.path)
|
||||||
path = append(path, m.Name)
|
path = append(path, m.Name)
|
||||||
|
|
||||||
// Split out the subdir if we have one
|
source, err := getter.Detect(m.Source, t.config.Dir, detectors)
|
||||||
source, subDir := getter.SourceDirSubdir(m.Source)
|
|
||||||
|
|
||||||
source, err := getter.Detect(source, t.config.Dir, detectors)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("module %s: %s", m.Name, err)
|
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
|
// Get the directory where this module is so we can load it
|
||||||
key := strings.Join(path, ".")
|
key := strings.Join(path, ".")
|
||||||
key = fmt.Sprintf("root.%s-%s", key, m.Source)
|
key = fmt.Sprintf("root.%s-%s", key, m.Source)
|
||||||
|
|
||||||
dir, ok, err := getStorage(s, key, source, mode)
|
dir, ok, err := getStorage(s, key, source, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
"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)
|
children[m.Name], err = NewTreeModule(m.Name, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
|
Loading…
Reference in New Issue