Fix 'Unexpected EOF' in builds without floppies

This commit is contained in:
Michael Kuzmin 2018-05-13 23:06:21 +03:00
parent 903febc4ea
commit 689f1789eb
2 changed files with 4 additions and 6 deletions

View File

@ -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
}

View File

@ -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
}