builder/virtualbox, vmware: delete output dir if cancelled
This commit is contained in:
parent
0486a90738
commit
98b4761ef1
|
@ -2,6 +2,7 @@ package virtualbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
|
"github.com/mitchellh/packer/packer"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,4 +19,15 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stepPrepareOutputDir) Cleanup(map[string]interface{}) {}
|
func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) {
|
||||||
|
_, cancelled := state[multistep.StateCancelled]
|
||||||
|
_, halted := state[multistep.StateHalted]
|
||||||
|
|
||||||
|
if cancelled || halted {
|
||||||
|
config := state["config"].(*config)
|
||||||
|
ui := state["ui"].(packer.Ui)
|
||||||
|
|
||||||
|
ui.Say("Deleting output directory...")
|
||||||
|
os.RemoveAll(config.OutputDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package vmware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
|
"github.com/mitchellh/packer/packer"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,4 +19,15 @@ func (stepPrepareOutputDir) Run(state map[string]interface{}) multistep.StepActi
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stepPrepareOutputDir) Cleanup(map[string]interface{}) {}
|
func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) {
|
||||||
|
_, cancelled := state[multistep.StateCancelled]
|
||||||
|
_, halted := state[multistep.StateHalted]
|
||||||
|
|
||||||
|
if cancelled || halted {
|
||||||
|
config := state["config"].(*config)
|
||||||
|
ui := state["ui"].(packer.Ui)
|
||||||
|
|
||||||
|
ui.Say("Deleting output directory...")
|
||||||
|
os.RemoveAll(config.OutputDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue