From 8e7b0d90e348b6760943835e1d9042ed52b7eb76 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 19 Jan 2016 12:19:32 -0800 Subject: [PATCH] config: detect provisioner-only resource in JSON and error [GH-4385] --- config/loader_hcl.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/loader_hcl.go b/config/loader_hcl.go index 59fe81795260..37e44565fbbe 100644 --- a/config/loader_hcl.go +++ b/config/loader_hcl.go @@ -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",