From 15255554685fb4086911c1d1d40a7a8b547b359e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 20 Sep 2013 11:18:00 -0700 Subject: [PATCH] packer: verify `except` has valid builders [GH-438] --- packer/template.go | 7 +++++++ packer/template_test.go | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packer/template.go b/packer/template.go index 32513d33f..cada49fd3 100644 --- a/packer/template.go +++ b/packer/template.go @@ -563,5 +563,12 @@ func (t *TemplateOnlyExcept) Validate(b map[string]RawBuilderConfig) (e []error) } } + for _, n := range t.Except { + if _, ok := b[n]; !ok { + e = append(e, + fmt.Errorf("'except' specified builder '%s' not found", n)) + } + } + return } diff --git a/packer/template_test.go b/packer/template_test.go index 3b14db021..62b1f54fa 100644 --- a/packer/template_test.go +++ b/packer/template_test.go @@ -707,7 +707,7 @@ func TestTemplateBuild_exeptPPInvalid(t *testing.T) { "post-processors": [ { "type": "test-pp", - "except": "test5" + "except": ["test5"] } ] } @@ -787,7 +787,7 @@ func TestTemplateBuild_exceptProvInvalid(t *testing.T) { "provisioners": [ { "type": "test-prov", - "except": "test5" + "except": ["test5"] } ] } @@ -867,7 +867,7 @@ func TestTemplateBuild_onlyPPInvalid(t *testing.T) { "post-processors": [ { "type": "test-pp", - "only": "test5" + "only": ["test5"] } ] } @@ -947,7 +947,7 @@ func TestTemplateBuild_onlyProvInvalid(t *testing.T) { "provisioners": [ { "type": "test-prov", - "only": "test5" + "only": ["test5"] } ] }