diff --git a/iso/step_add_floppy.go b/iso/step_add_floppy.go index f11fa5e83..f03511452 100644 --- a/iso/step_add_floppy.go +++ b/iso/step_add_floppy.go @@ -25,8 +25,7 @@ func (s *StepAddFloppy) Run(_ context.Context, state multistep.StateBag) multist vm := state.Get("vm").(*driver.VirtualMachine) d := state.Get("driver").(*driver.Driver) - tmpFloppy := state.Get("floppy_path").(string) - if tmpFloppy != "" { + if floppyPath, ok := state.GetOk("floppy_path"); ok { ui.Say("Uploading created floppy image") ds, err := d.FindDatastore(s.Datastore, s.Host) @@ -41,7 +40,7 @@ func (s *StepAddFloppy) Run(_ context.Context, state multistep.StateBag) multist } uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.flp", vmDir) - if err := ds.UploadFile(tmpFloppy, uploadPath); err != nil { + if err := ds.UploadFile(floppyPath.(string), uploadPath); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/iso/step_remove_floppy.go b/iso/step_remove_floppy.go index f9871c48c..3a1a2d762 100644 --- a/iso/step_remove_floppy.go +++ b/iso/step_remove_floppy.go @@ -30,15 +30,14 @@ func (s *StepRemoveFloppy) Run(_ context.Context, state multistep.StateBag) mult return multistep.ActionHalt } - UploadedFloppyPath := state.Get("uploaded_floppy_path").(string) - if UploadedFloppyPath != "" { + if UploadedFloppyPath, ok := state.GetOk("uploaded_floppy_path"); ok { ui.Say("Deleting Floppy image...") ds, err := d.FindDatastore(s.Datastore, s.Host) if err != nil { state.Put("error", err) return multistep.ActionHalt } - if err := ds.Delete(UploadedFloppyPath); err != nil { + if err := ds.Delete(UploadedFloppyPath.(string)); err != nil { state.Put("error", err) return multistep.ActionHalt }