Update vmware/govmomi godeps

This commit is contained in:
Doug MacEachern
2017-11-16 20:13:29 -08:00
parent 8a9954d471
commit 09da53c8e9
125 changed files with 26926 additions and 934 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -60,6 +60,7 @@ const (
type header struct {
Cookie string `xml:"vcSessionCookie,omitempty"`
ID string `xml:"operationID,omitempty"`
}
type Client struct {
@@ -78,7 +79,7 @@ type Client struct {
Version string // Vim version
UserAgent string
header *header
cookie string
}
var schemeMatch = regexp.MustCompile(`^\w+://`)
@@ -168,10 +169,7 @@ func (c *Client) NewServiceClient(path string, namespace string) *Client {
// Set SOAP Header cookie
for _, cookie := range client.Jar.Cookies(u) {
if cookie.Name == "vmware_soap_session" {
client.header = &header{
Cookie: cookie.Value,
}
client.cookie = cookie.Value
break
}
}
@@ -433,7 +431,15 @@ func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error
reqEnv := Envelope{Body: reqBody}
resEnv := Envelope{Body: resBody}
reqEnv.Header = c.header
h := &header{
Cookie: c.cookie,
}
if id, ok := ctx.Value(types.ID{}).(string); ok {
h.ID = id
}
reqEnv.Header = h
// Create debugging context for this round trip
d := c.d.newRoundTrip()
@@ -614,6 +620,7 @@ type Download struct {
Headers map[string]string
Ticket *http.Cookie
Progress progress.Sinker
Writer io.Writer
}
var DefaultDownload = Download{
@@ -655,7 +662,46 @@ func (c *Client) Download(u *url.URL, param *Download) (io.ReadCloser, int64, er
return nil, 0, err
}
return res.Body, res.ContentLength, nil
r := res.Body
return r, res.ContentLength, nil
}
func (c *Client) WriteFile(file string, src io.Reader, size int64, s progress.Sinker, w io.Writer) error {
var err error
r := src
fh, err := os.Create(file)
if err != nil {
return err
}
if s != nil {
pr := progress.NewReader(s, src, size)
src = pr
// Mark progress reader as done when returning from this function.
defer func() {
pr.Done(err)
}()
}
if w == nil {
w = fh
} else {
w = io.MultiWriter(w, fh)
}
_, err = io.Copy(w, r)
cerr := fh.Close()
if err == nil {
err = cerr
}
return err
}
// DownloadFile GETs the given URL to a local file
@@ -669,37 +715,6 @@ func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
if err != nil {
return err
}
defer rc.Close()
var r io.Reader = rc
fh, err := os.Create(file)
if err != nil {
return err
}
defer fh.Close()
if param.Progress != nil {
pr := progress.NewReader(param.Progress, r, contentLength)
r = pr
// Mark progress reader as done when returning from this function.
defer func() {
pr.Done(err)
}()
}
_, err = io.Copy(fh, r)
if err != nil {
return err
}
// Assign error before returning so that it gets picked up by the deferred
// function marking the progress reader as done.
err = fh.Close()
if err != nil {
return err
}
return nil
return c.WriteFile(file, rc, contentLength, param.Progress, param.Writer)
}