packer-cn/builder/hyperv/common/step_unmount_floppydrive.go

41 lines
854 B
Go
Raw Normal View History

package common
import (
"context"
"fmt"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/packer"
2020-11-17 19:31:03 -05:00
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
)
type StepUnmountFloppyDrive struct {
Generation uint
}
func (s *StepUnmountFloppyDrive) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui)
if s.Generation > 1 {
return multistep.ActionContinue
}
vmName := state.Get("vmName").(string)
ui.Say("Unmount/delete floppy drive (Run)...")
2016-11-06 11:02:00 -05:00
errorMsg := "Error Unmounting floppy drive: %s"
err := driver.UnmountFloppyDrive(vmName)
if err != nil {
err := fmt.Errorf(errorMsg, err)
state.Put("error", err)
ui.Error(err.Error())
}
return multistep.ActionContinue
}
func (s *StepUnmountFloppyDrive) Cleanup(state multistep.StateBag) {
// do nothing
}