clean up folder path so that it is what vsphere expects

This commit is contained in:
Joshua Foster 2020-07-07 12:25:14 -04:00
parent 03d29386dd
commit a6170b0c35
1 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,11 @@
package common package common
import "fmt" import (
"fmt"
"path"
"strings"
)
type LocationConfig struct { type LocationConfig struct {
// Name of the new VM to create. // 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")) 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 return errs
} }