Add an explicit error message when there is no output file specified

This commit is contained in:
Chris Bednarski 2015-08-18 13:48:18 -07:00
parent 51002e8c6f
commit 32978a5109
1 changed files with 10 additions and 1 deletions

View File

@ -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 {