config/module: walk actually recurses into dirs, don't copy dot-prefix

This commit is contained in:
Mitchell Hashimoto 2014-10-03 13:46:19 -07:00
parent 238ec05f2f
commit f35ebe7032
4 changed files with 27 additions and 2 deletions

View File

@ -26,7 +26,7 @@ func copyDir(dst, src string) error {
basePath := filepath.Base(path)
if strings.HasPrefix(basePath, ".") {
// Skip any dot files
return nil
return filepath.SkipDir
}
dstPath := filepath.Join(dst, basePath)
@ -38,7 +38,7 @@ func copyDir(dst, src string) error {
return err
}
return copyDir(dstPath, path)
return nil
}
// If we have a file, copy the contents.

View File

@ -60,6 +60,25 @@ func TestGet_fileSubdir(t *testing.T) {
}
}
func TestGetCopy_dot(t *testing.T) {
dst := tempDir(t)
u := testModule("basic-dot")
if err := GetCopy(dst, u); err != nil {
t.Fatalf("err: %s", err)
}
mainPath := filepath.Join(dst, "main.tf")
if _, err := os.Stat(mainPath); err != nil {
t.Fatalf("err: %s", err)
}
mainPath = filepath.Join(dst, "foo.tf")
if _, err := os.Stat(mainPath); err == nil {
t.Fatal("should not have foo.tf")
}
}
func TestGetCopy_file(t *testing.T) {
dst := tempDir(t)
u := testModule("basic")

View File

@ -0,0 +1 @@
# Hi

View File

@ -0,0 +1,5 @@
# Hello
module "foo" {
source = "./foo"
}