Skip to content

Commit

Permalink
Merge pull request #4746 from hashicorp/b-detect-weird-json
Browse files Browse the repository at this point in the history
config: detect provisioner-only resource in JSON and error [GH-4385]
  • Loading branch information
mitchellh committed Jan 19, 2016
2 parents 7ab19c6 + 8e7b0d9 commit 585d094
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/loader_hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,15 @@ func loadResourcesHcl(list *ast.ObjectList) ([]*Resource, error) {
// Now go over all the types and their children in order to get
// all of the actual resources.
for _, item := range list.Items {
// GH-4385: We detect a pure provisioner resource and give the user
// an error about how to do it cleanly.
if len(item.Keys) == 4 && item.Keys[2].Token.Value().(string) == "provisioner" {
return nil, fmt.Errorf(
"position %s: provisioners in a resource should be wrapped in a list\n\n"+
"Example: \"provisioner\": [ { \"local-exec\": ... } ]",
item.Pos())
}

if len(item.Keys) != 2 {
return nil, fmt.Errorf(
"position %s: resource must be followed by exactly two strings, a type and a name",
Expand Down

0 comments on commit 585d094

Please sign in to comment.