From 3f80414e6d5423ac5b5e3ea9a6580b9b5761ca1c Mon Sep 17 00:00:00 2001 From: Joshua Foster Date: Sun, 16 Feb 2020 09:08:28 -0500 Subject: [PATCH] fix #8743 by using interface instead of Network object --- builder/vsphere/driver/network.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/builder/vsphere/driver/network.go b/builder/vsphere/driver/network.go index de923a01d..89f491c12 100644 --- a/builder/vsphere/driver/network.go +++ b/builder/vsphere/driver/network.go @@ -1,6 +1,8 @@ package driver import ( + "fmt" + "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/types" @@ -8,7 +10,7 @@ import ( type Network struct { driver *Driver - network *object.Network + network object.NetworkReference } func (d *Driver) NewNetwork(ref *types.ManagedObjectReference) *Network { @@ -24,7 +26,7 @@ func (d *Driver) FindNetwork(name string) (*Network, error) { return nil, err } return &Network{ - network: n.(*object.Network), + network: n, driver: d, }, nil } @@ -37,7 +39,13 @@ func (n *Network) Info(params ...string) (*mo.Network, error) { p = params } var info mo.Network - err := n.network.Properties(n.driver.ctx, n.network.Reference(), p, &info) + + network, ok := n.network.(*object.Network) + if !ok { + return nil, fmt.Errorf("unexpected %t network object type", n.network) + } + + err := network.Properties(n.driver.ctx, network.Reference(), p, &info) if err != nil { return nil, err }