config: LoadDir with no matching files errors

This commit is contained in:
Mitchell Hashimoto 2014-07-11 21:04:59 -07:00
parent 6bf543cb07
commit 7a01e781ab
3 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package config
import (
"fmt"
"path/filepath"
)
@ -35,6 +36,12 @@ func LoadDir(path string) (*Config, error) {
return nil, err
}
if len(matches) == 0 {
return nil, fmt.Errorf(
"No Terraform configuration files found in directory: %s",
path)
}
var result *Config
for _, f := range matches {
c, err := Load(f)

View File

@ -128,6 +128,13 @@ func TestLoadDir_basic(t *testing.T) {
}
}
func TestLoadDir_noConfigs(t *testing.T) {
_, err := LoadDir(filepath.Join(fixtureDir, "dir-empty"))
if err == nil {
t.Fatal("should error")
}
}
func outputsStr(os map[string]*Output) string {
ns := make([]string, 0, len(os))
for n, _ := range os {

View File