diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index 39c5a4e76..a806460f2 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -8,6 +8,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/mitchellh/packer/packer" "log" + "text/template" ) var builtins = map[string]string{ @@ -31,7 +32,12 @@ func (p *PostProcessor) Configure(raw interface{}) error { } if p.config.OutputPath == "" { - return fmt.Errorf("`output` must be specified.") + p.config.OutputPath = "packer_{{.Provider}}.box" + } + + _, err = template.New("output").Parse(p.config.OutputPath) + if err != nil { + return fmt.Errorf("output invalid template: %s", err) } mapConfig, ok := raw.(map[string]interface{}) diff --git a/post-processor/vagrant/post-processor_test.go b/post-processor/vagrant/post-processor_test.go index da37b7b04..210e74546 100644 --- a/post-processor/vagrant/post-processor_test.go +++ b/post-processor/vagrant/post-processor_test.go @@ -20,10 +20,18 @@ func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { func TestBuilderPrepare_OutputPath(t *testing.T) { var p PostProcessor + // Default c := testConfig() delete(c, "output") err := p.Configure(c) + if err != nil { + t.Fatalf("err: %s", err) + } + + // Bad template + c["output"] = "bad {{{{.Template}}}}" + err = p.Configure(c) if err == nil { - t.Fatalf("configure should fail") + t.Fatal("should have error") } }