From c7a6315ca48db248ab52d66e8213e3c97a758ab7 Mon Sep 17 00:00:00 2001 From: Joshua Foster Date: Wed, 10 Jun 2020 08:24:23 -0400 Subject: [PATCH 1/2] use datacenter inventory path for find folder --- builder/vsphere/driver/folder.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/builder/vsphere/driver/folder.go b/builder/vsphere/driver/folder.go index ab0c966d6..080cf240d 100644 --- a/builder/vsphere/driver/folder.go +++ b/builder/vsphere/driver/folder.go @@ -21,12 +21,7 @@ func (d *Driver) NewFolder(ref *types.ManagedObjectReference) *Folder { } func (d *Driver) FindFolder(name string) (*Folder, error) { - folders, err := d.datacenter.Folders(d.ctx) - if err != nil { - return nil, err - } - - f, err := d.finder.Folder(d.ctx, fmt.Sprintf("%v/%v", folders.VmFolder.InventoryPath, name)) + f, err := d.finder.Folder(d.ctx, fmt.Sprintf("%v/vm/%v", d.datacenter.InventoryPath, name)) if err != nil { return nil, err } From f5a795a22e4236058214ed16d8d75cb31fcbb8d6 Mon Sep 17 00:00:00 2001 From: Joshua Foster Date: Wed, 10 Jun 2020 09:12:21 -0400 Subject: [PATCH 2/2] use path.Join to make a cleaner path --- builder/vsphere/driver/folder.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/vsphere/driver/folder.go b/builder/vsphere/driver/folder.go index 080cf240d..f788772b4 100644 --- a/builder/vsphere/driver/folder.go +++ b/builder/vsphere/driver/folder.go @@ -2,6 +2,7 @@ package driver import ( "fmt" + "path" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/vim25/mo" @@ -21,7 +22,7 @@ func (d *Driver) NewFolder(ref *types.ManagedObjectReference) *Folder { } func (d *Driver) FindFolder(name string) (*Folder, error) { - f, err := d.finder.Folder(d.ctx, fmt.Sprintf("%v/vm/%v", d.datacenter.InventoryPath, name)) + f, err := d.finder.Folder(d.ctx, path.Join(d.datacenter.InventoryPath, "vm", name)) if err != nil { return nil, err }