Fix 'Unexpected EOF' in builds without floppies
This commit is contained in:
parent
903febc4ea
commit
689f1789eb
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue