builder/docker: create export dir if needed
This commit is contained in:
parent
198824a25f
commit
9e2d69fb97
|
@ -3,6 +3,7 @@ package docker
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
|
@ -26,6 +27,13 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
return multistep.ActionHalt
|
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
|
// Open the file that we're going to write to
|
||||||
f, err := os.Create(config.ExportPath)
|
f, err := os.Create(config.ExportPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue