Merge pull request #4439 from mitchellh/fix2626

builder/docker: create export dir if needed
pull/4443/head
Matthew Hooker 9 years ago committed by GitHub
commit fb5ae138ab

@ -3,6 +3,7 @@ package docker
import (
"fmt"
"os"
"path/filepath"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
@ -26,6 +27,13 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt
}
// Make the directory we're exporting to if it doesn't exist
exportDir := filepath.Dir(config.ExportPath)
if err := os.MkdirAll(exportDir, 0755); err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
// Open the file that we're going to write to
f, err := os.Create(config.ExportPath)
if err != nil {

Loading…
Cancel
Save