check vcenter url for /sdk
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
20
main.go
20
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/govmomi"
|
||||
@@ -17,10 +18,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
c *govmomi.Client
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
location *time.Location
|
||||
c *govmomi.Client
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
location *time.Location
|
||||
sha1ver string // sha1 revision used to build the program
|
||||
buildTime string // when the executable was built
|
||||
)
|
||||
|
||||
func getEvents(eventTypes []string, entities []types.ManagedObjectReference, begin time.Duration, end time.Duration) []types.Event {
|
||||
@@ -102,13 +105,20 @@ func main() {
|
||||
// So we can convert vCenter UTC to our local timezone
|
||||
location, _ = time.LoadLocation(*vTZ)
|
||||
|
||||
fmt.Printf("Starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
|
||||
|
||||
u, err := url.Parse(*vURL)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error parsing url %s : %s\n", *vURL, err)
|
||||
os.Exit(1)
|
||||
} else {
|
||||
if !strings.HasSuffix(u.Path, "/sdk") {
|
||||
u.Path, _ = url.JoinPath(u.Path, "/sdk")
|
||||
fmt.Printf("Updated vCenter URL to '%v'\n", u)
|
||||
}
|
||||
}
|
||||
|
||||
//fmt.Printf("Connecting to vCenter %s\n", u)
|
||||
fmt.Printf("Connecting to vCenter %s\n", u)
|
||||
u.User = url.UserPassword(*vUser, *vPass)
|
||||
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
|
Reference in New Issue
Block a user