From a6170b0c35025b2ff097fac756e2c8334145eba5 Mon Sep 17 00:00:00 2001 From: Joshua Foster Date: Tue, 7 Jul 2020 12:25:14 -0400 Subject: [PATCH] clean up folder path so that it is what vsphere expects --- builder/vsphere/common/config_location.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/builder/vsphere/common/config_location.go b/builder/vsphere/common/config_location.go index 1eda68ac7..99d444224 100644 --- a/builder/vsphere/common/config_location.go +++ b/builder/vsphere/common/config_location.go @@ -3,7 +3,11 @@ package common -import "fmt" +import ( + "fmt" + "path" + "strings" +) type LocationConfig struct { // Name of the new VM to create. @@ -38,5 +42,9 @@ func (c *LocationConfig) Prepare() []error { errs = append(errs, fmt.Errorf("'host' or 'cluster' is required")) } + // clean Folder path and remove leading slash as folders are relative within vsphere + c.Folder = path.Clean(c.Folder) + c.Folder = strings.TrimLeft(c.Folder, "/") + return errs }