builer/virtualbox: avoid crash since guest additions path not set

This commit is contained in:
Mitchell Hashimoto 2013-12-18 11:27:25 -08:00
parent 675f7a43ba
commit c264ef0a29
2 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,6 @@ type stepAttachGuestAdditions struct {
func (s *stepAttachGuestAdditions) Run(state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(*config)
driver := state.Get("driver").(Driver)
guestAdditionsPath := state.Get("guest_additions_path").(string)
ui := state.Get("ui").(packer.Ui)
vmName := state.Get("vmName").(string)
@ -35,6 +34,9 @@ func (s *stepAttachGuestAdditions) Run(state multistep.StateBag) multistep.StepA
return multistep.ActionContinue
}
// Get the guest additions path since we're doing it
guestAdditionsPath := state.Get("guest_additions_path").(string)
// Attach the guest additions to the computer
log.Println("Attaching guest additions ISO onto IDE controller...")
command := []string{

View File

@ -19,7 +19,6 @@ func (s *stepUploadGuestAdditions) Run(state multistep.StateBag) multistep.StepA
comm := state.Get("communicator").(packer.Communicator)
config := state.Get("config").(*config)
driver := state.Get("driver").(Driver)
guestAdditionsPath := state.Get("guest_additions_path").(string)
ui := state.Get("ui").(packer.Ui)
// If we're attaching then don't do this, since we attached.
@ -28,6 +27,9 @@ func (s *stepUploadGuestAdditions) Run(state multistep.StateBag) multistep.StepA
return multistep.ActionContinue
}
// Get the guest additions path since we're doing it
guestAdditionsPath := state.Get("guest_additions_path").(string)
version, err := driver.Version()
if err != nil {
state.Put("error", fmt.Errorf("Error reading version for guest additions upload: %s", err))