builder/vmware/common: StepCleanFiles
This commit is contained in:
parent
95e0e465cf
commit
8f8ea60b4f
@ -1,4 +1,4 @@
|
|||||||
package iso
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -21,9 +21,9 @@ var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"}
|
|||||||
//
|
//
|
||||||
// Produces:
|
// Produces:
|
||||||
// <nothing>
|
// <nothing>
|
||||||
type stepCleanFiles struct{}
|
type StepCleanFiles struct{}
|
||||||
|
|
||||||
func (stepCleanFiles) Run(state multistep.StateBag) multistep.StepAction {
|
func (StepCleanFiles) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
dir := state.Get("dir").(OutputDir)
|
dir := state.Get("dir").(OutputDir)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
@ -49,7 +49,9 @@ func (stepCleanFiles) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
if !keep {
|
if !keep {
|
||||||
ui.Message(fmt.Sprintf("Deleting: %s", path))
|
ui.Message(fmt.Sprintf("Deleting: %s", path))
|
||||||
if err = dir.Remove(path); err != nil {
|
if err = dir.Remove(path); err != nil {
|
||||||
// Only report the error if the file still exists
|
// Only report the error if the file still exists. We do this
|
||||||
|
// because sometimes the files naturally get removed on their
|
||||||
|
// own as VMware does its own cleanup.
|
||||||
if _, serr := os.Stat(path); serr == nil || !os.IsNotExist(serr) {
|
if _, serr := os.Stat(path); serr == nil || !os.IsNotExist(serr) {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
@ -61,4 +63,4 @@ func (stepCleanFiles) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stepCleanFiles) Cleanup(multistep.StateBag) {}
|
func (StepCleanFiles) Cleanup(multistep.StateBag) {}
|
@ -411,7 +411,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||||||
&stepUploadTools{},
|
&stepUploadTools{},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
&stepShutdown{},
|
&stepShutdown{},
|
||||||
&stepCleanFiles{},
|
&vmwcommon.StepCleanFiles{},
|
||||||
&stepCleanVMX{},
|
&stepCleanVMX{},
|
||||||
&stepCompactDisk{},
|
&stepCompactDisk{},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user