From d4d5c1e7db187b5ea918b7bb95d3fd825066a3f2 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 22 Aug 2018 11:22:24 -0700 Subject: [PATCH] vsphere: adjust to govmomi tags API changes --- pkg/cloudprovider/providers/vsphere/vsphere.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/cloudprovider/providers/vsphere/vsphere.go b/pkg/cloudprovider/providers/vsphere/vsphere.go index 441c46ec718..e9fdfbc821b 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere.go @@ -34,7 +34,7 @@ import ( "gopkg.in/gcfg.v1" "github.com/golang/glog" - _ "github.com/vmware/govmomi/vapi/rest" + "github.com/vmware/govmomi/vapi/rest" "github.com/vmware/govmomi/vapi/tags" "k8s.io/api/core/v1" k8stypes "k8s.io/apimachinery/pkg/types" @@ -1319,11 +1319,10 @@ func (vs *VSphere) NodeManager() (nodeManager *NodeManager) { return vs.nodeManager } -func withTagsClient(ctx context.Context, connection *vclib.VSphereConnection, f func(c *tags.RestClient) error) error { - vsURL := connection.Client.URL() - vsURL.User = url.UserPassword(connection.Username, connection.Password) - c := tags.NewClient(vsURL, connection.Insecure, "") - if err := c.Login(ctx); err != nil { +func withTagsClient(ctx context.Context, connection *vclib.VSphereConnection, f func(c *rest.Client) error) error { + c := rest.NewClient(connection.Client) + user := url.UserPassword(connection.Username, connection.Password) + if err := c.Login(ctx, user); err != nil { return err } defer c.Logout(ctx) @@ -1354,7 +1353,8 @@ func (vs *VSphere) GetZone(ctx context.Context) (cloudprovider.Zone, error) { return cloudprovider.Zone{}, err } client := vsi.conn - err = withTagsClient(ctx, client, func(client *tags.RestClient) error { + err = withTagsClient(ctx, client, func(c *rest.Client) error { + client := tags.NewManager(c) tags, err := client.ListAttachedTags(ctx, vmHost) if err != nil { glog.Errorf("Cannot list attached tags. Get zone for node %s error", nodeName)