Check if task result is nil and return error (#9354)
This commit is contained in:
parent
8e4a3662ca
commit
434c9bcae0
|
@ -59,9 +59,10 @@
|
|||
* builder/vagrant: Use absolute path for package_include files to prevent them
|
||||
from having to be relative to the output vagrant directory. [GH-9260]
|
||||
* builder/virtualbox: Fix bug using checksum files. [GH-9101]
|
||||
* builder/vSphere: Add option not to set host during datastore upload. [GH-9100
|
||||
* builder/vsphere: Add option not to set host during datastore upload. [GH-9100
|
||||
* builder/vsphere: Fix iso config prepare being called incorrectly, which
|
||||
caused `iso_url` field to fail. [GH-9197]
|
||||
* builder/vsphere: Fix crash in the driver for an interface conversion of types.AnyType nil to types.ManagedObjectReference. [GH-9354]
|
||||
* core: Ensure HTTP server information `PackerHTTPIP`, `PackerHTTPPort`, and
|
||||
`PackerHTTPAddr` are available via the `build` template engine for all
|
||||
supported builders [GH-9238]
|
||||
|
|
|
@ -205,7 +205,10 @@ func (d *Driver) CreateVM(config *CreateConfig) (*VirtualMachine, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
vmRef := taskInfo.Result.(types.ManagedObjectReference)
|
||||
vmRef, ok := taskInfo.Result.(types.ManagedObjectReference)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("something went wrong when creating the VM")
|
||||
}
|
||||
|
||||
return d.NewVM(&vmRef), nil
|
||||
}
|
||||
|
@ -326,7 +329,11 @@ func (vm *VirtualMachine) Clone(ctx context.Context, config *CloneConfig) (*Virt
|
|||
return nil, err
|
||||
}
|
||||
|
||||
vmRef := info.Result.(types.ManagedObjectReference)
|
||||
vmRef, ok := info.Result.(types.ManagedObjectReference)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("something went wrong when cloning the VM")
|
||||
}
|
||||
|
||||
created := vm.driver.NewVM(&vmRef)
|
||||
return created, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue