Merge pull request #9823 from hashicorp/b-unnamed-output
config: validate that outputs have a name
This commit is contained in:
commit
060ed2f708
|
@ -324,7 +324,8 @@ func loadModulesHcl(list *ast.ObjectList) ([]*Module, error) {
|
||||||
func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
|
func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
|
||||||
list = list.Children()
|
list = list.Children()
|
||||||
if len(list.Items) == 0 {
|
if len(list.Items) == 0 {
|
||||||
return nil, nil
|
return nil, fmt.Errorf(
|
||||||
|
"'output' must be followed by exactly one string: a name")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through each object and turn it into an actual result.
|
// Go through each object and turn it into an actual result.
|
||||||
|
|
|
@ -565,6 +565,18 @@ func TestLoadFile_provisioners(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadFile_unnamedOutput(t *testing.T) {
|
||||||
|
_, err := LoadFile(filepath.Join(fixtureDir, "output-unnamed.tf"))
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("bad: expected error")
|
||||||
|
}
|
||||||
|
|
||||||
|
errorStr := err.Error()
|
||||||
|
if !strings.Contains(errorStr, "'output' must be followed") {
|
||||||
|
t.Fatalf("bad: expected error has wrong text: %s", errorStr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLoadFile_connections(t *testing.T) {
|
func TestLoadFile_connections(t *testing.T) {
|
||||||
c, err := LoadFile(filepath.Join(fixtureDir, "connection.tf"))
|
c, err := LoadFile(filepath.Join(fixtureDir, "connection.tf"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
output {
|
||||||
|
value = "foo"
|
||||||
|
}
|
Loading…
Reference in New Issue