builder/vmware: Double check that OutputDirectory does not already exist
The initial check in Builder.Prepare does not use the OutputDir interface. stepPrepareOutputDir also checks if OutputDir exists, error out there unless using -force so we get the same behavior when RemoteType is esx5.
This commit is contained in:
parent
3f5a02cf2a
commit
4af1c7f1b2
|
@ -1,6 +1,7 @@
|
|||
package vmware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"log"
|
||||
|
@ -24,9 +25,14 @@ func (s *stepPrepareOutputDir) Run(state multistep.StateBag) multistep.StepActio
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
if exists && config.PackerForce {
|
||||
ui.Say("Deleting previous output directory...")
|
||||
dir.RemoveAll()
|
||||
if exists {
|
||||
if config.PackerForce {
|
||||
ui.Say("Deleting previous output directory...")
|
||||
dir.RemoveAll()
|
||||
} else {
|
||||
state.Put("error", fmt.Errorf("Output directory '%s' already exists.", config.OutputDir))
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
|
||||
if err := dir.MkdirAll(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue