config: LoadDir with no matching files errors
This commit is contained in:
parent
6bf543cb07
commit
7a01e781ab
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,6 +36,12 @@ func LoadDir(path string) (*Config, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(matches) == 0 {
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"No Terraform configuration files found in directory: %s",
|
||||||
|
path)
|
||||||
|
}
|
||||||
|
|
||||||
var result *Config
|
var result *Config
|
||||||
for _, f := range matches {
|
for _, f := range matches {
|
||||||
c, err := Load(f)
|
c, err := Load(f)
|
||||||
|
|
|
@ -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 {
|
func outputsStr(os map[string]*Output) string {
|
||||||
ns := make([]string, 0, len(os))
|
ns := make([]string, 0, len(os))
|
||||||
for n, _ := range os {
|
for n, _ := range os {
|
||||||
|
|
Loading…
Reference in New Issue