From 32978a5109ae348de759b6dfab055567b69921b1 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 18 Aug 2015 13:48:18 -0700 Subject: [PATCH] Add an explicit error message when there is no output file specified --- builder/docker/step_export.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/docker/step_export.go b/builder/docker/step_export.go index aa949b610..6fbdcb63d 100644 --- a/builder/docker/step_export.go +++ b/builder/docker/step_export.go @@ -2,9 +2,10 @@ package docker import ( "fmt" + "os" + "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" - "os" ) // StepExport exports the container to a flat tar file. @@ -17,6 +18,14 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { containerId := state.Get("container_id").(string) ui := state.Get("ui").(packer.Ui) + // We should catch this in validation, but guard anyway + if config.ExportPath == "" { + err := fmt.Errorf("No output file specified, we can't export anything") + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + // Open the file that we're going to write to f, err := os.Create(config.ExportPath) if err != nil {