mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 16:10:46 -06:00
config: LoadDir with no matching files errors
This commit is contained in:
parent
6bf543cb07
commit
7a01e781ab
@ -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)
|
||||
|
@ -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 {
|
||||
|
0
config/test-fixtures/dir-empty/.gitkeep
Normal file
0
config/test-fixtures/dir-empty/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user