Merge pull request #9823 from hashicorp/b-unnamed-output

config: validate that outputs have a name
This commit is contained in:
Mitchell Hashimoto 2016-11-04 08:47:29 -07:00 committed by GitHub
commit 060ed2f708
3 changed files with 17 additions and 1 deletions

View File

@ -324,7 +324,8 @@ func loadModulesHcl(list *ast.ObjectList) ([]*Module, error) {
func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
list = list.Children()
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.

View File

@ -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) {
c, err := LoadFile(filepath.Join(fixtureDir, "connection.tf"))
if err != nil {

View File

@ -0,0 +1,3 @@
output {
value = "foo"
}