From dca2b515a3588fcbbde18b1830956fb83748b176 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Wed, 18 May 2016 17:18:46 -0700 Subject: [PATCH] Update to go-autorest v7.0.5. (#3554) --- Godeps/Godeps.json | 17 ++++++++--------- .../Azure/go-autorest/autorest/azure/async.go | 12 ++++++++---- .../Azure/go-autorest/autorest/azure/persist.go | 6 +++--- .../Azure/go-autorest/autorest/client.go | 9 +++++++-- .../Azure/go-autorest/autorest/responder.go | 8 ++++++-- .../Azure/go-autorest/autorest/sender.go | 13 +++++-------- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 253bd009b..44de099b8 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,6 @@ { "ImportPath": "github.com/mitchellh/packer", "GoVersion": "go1.6", - "GodepVersion": "v62", "Deps": [ { "ImportPath": "github.com/ActiveState/tail", @@ -40,23 +39,23 @@ }, { "ImportPath": "github.com/Azure/go-autorest/autorest", - "Comment": "v7.0.4", - "Rev": "b01ec2b60f95678fa759f796bac3c6b9bceaead4" + "Comment": "v7.0.5", + "Rev": "4bdf29b663ebad9598d2c391b73a4b46bdedbf42" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/azure", - "Comment": "v7.0.4", - "Rev": "b01ec2b60f95678fa759f796bac3c6b9bceaead4" + "Comment": "v7.0.5", + "Rev": "4bdf29b663ebad9598d2c391b73a4b46bdedbf42" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/date", - "Comment": "v7.0.4", - "Rev": "b01ec2b60f95678fa759f796bac3c6b9bceaead4" + "Comment": "v7.0.5", + "Rev": "4bdf29b663ebad9598d2c391b73a4b46bdedbf42" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/to", - "Comment": "v7.0.4", - "Rev": "b01ec2b60f95678fa759f796bac3c6b9bceaead4" + "Comment": "v7.0.5", + "Rev": "4bdf29b663ebad9598d2c391b73a4b46bdedbf42" }, { "ImportPath": "github.com/Azure/go-ntlmssp", diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/async.go b/vendor/github.com/Azure/go-autorest/autorest/azure/async.go index 147527751..93fa25b99 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/async.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/async.go @@ -39,6 +39,10 @@ func DoPollForAsynchronous(delay time.Duration) autorest.SendDecorator { if err != nil { return resp, err } + pollingCodes := []int{http.StatusAccepted, http.StatusCreated, http.StatusOK} + if !autorest.ResponseHasStatusCode(resp, pollingCodes...) { + return resp, nil + } ps := pollingState{} for err == nil { @@ -224,10 +228,6 @@ func updatePollingState(resp *http.Response, ps *pollingState) error { ps.uri = req.URL.String() } } - - if ps.uri == "" { - return autorest.NewError("azure", "updatePollingState", "Azure Polling Error - Unable to obtain polling URI for %s %s", req.Method, req.RequestURI) - } } // Read and interpret the response (saving the Body in case no polling is necessary) @@ -262,6 +262,10 @@ func updatePollingState(resp *http.Response, ps *pollingState) error { } } + if ps.state == operationInProgress && ps.uri == "" { + return autorest.NewError("azure", "updatePollingState", "Azure Polling Error - Unable to obtain polling URI for %s %s", resp.Request.Method, resp.Request.URL) + } + // For failed operation, check for error code and message in // -- Operation resource // -- Response diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/persist.go b/vendor/github.com/Azure/go-autorest/autorest/azure/persist.go index a00e6b1c7..db8bdce48 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/persist.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/persist.go @@ -34,13 +34,13 @@ func SaveToken(path string, mode os.FileMode, token Token) error { return fmt.Errorf("failed to create directory (%s) to store token in: %v", dir, err) } - newFile, err := ioutil.TempFile(os.TempDir(), "token") + newFile, err := ioutil.TempFile(dir, "token") if err != nil { return fmt.Errorf("failed to create the temp file to write the token: %v", err) } tempPath := newFile.Name() - if json.NewEncoder(newFile).Encode(token); err != nil { + if err := json.NewEncoder(newFile).Encode(token); err != nil { return fmt.Errorf("failed to encode token to file (%s) while saving token: %v", tempPath, err) } if err := newFile.Close(); err != nil { @@ -49,7 +49,7 @@ func SaveToken(path string, mode os.FileMode, token Token) error { // Atomic replace to avoid multi-writer file corruptions if err := os.Rename(tempPath, path); err != nil { - return fmt.Errorf("failed to move temporary token to desired output location. source=(%s). destination=(%s). error = %v", tempPath, path, err) + return fmt.Errorf("failed to move temporary token to desired output location. src=%s dst=%s: %v", tempPath, path, err) } if err := os.Chmod(path, mode); err != nil { return fmt.Errorf("failed to chmod the token file %s: %v", path, err) diff --git a/vendor/github.com/Azure/go-autorest/autorest/client.go b/vendor/github.com/Azure/go-autorest/autorest/client.go index ffa2ebaa7..ce156f74f 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/client.go +++ b/vendor/github.com/Azure/go-autorest/autorest/client.go @@ -2,6 +2,7 @@ package autorest import ( "bytes" + "fmt" "io" "io/ioutil" "log" @@ -53,7 +54,9 @@ func (li LoggingInspector) WithInspection() PrepareDecorator { defer r.Body.Close() r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &body)) - r.Write(&b) + if err := r.Write(&b); err != nil { + return nil, fmt.Errorf("Failed to write response: %v", err) + } li.Logger.Printf(requestFormat, b.String()) @@ -76,7 +79,9 @@ func (li LoggingInspector) ByInspecting() RespondDecorator { defer resp.Body.Close() resp.Body = ioutil.NopCloser(io.TeeReader(resp.Body, &body)) - resp.Write(&b) + if err := resp.Write(&b); err != nil { + return fmt.Errorf("Failed to write response: %v", err) + } li.Logger.Printf(responseFormat, b.String()) diff --git a/vendor/github.com/Azure/go-autorest/autorest/responder.go b/vendor/github.com/Azure/go-autorest/autorest/responder.go index 51d69c5a2..e377ad48a 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/responder.go +++ b/vendor/github.com/Azure/go-autorest/autorest/responder.go @@ -95,7 +95,9 @@ func ByClosing() RespondDecorator { return ResponderFunc(func(resp *http.Response) error { err := r.Respond(resp) if resp != nil && resp.Body != nil { - resp.Body.Close() + if err := resp.Body.Close(); err != nil { + return fmt.Errorf("Error closing the response body: %v", err) + } } return err }) @@ -109,7 +111,9 @@ func ByClosingIfError() RespondDecorator { return ResponderFunc(func(resp *http.Response) error { err := r.Respond(resp) if err != nil && resp != nil && resp.Body != nil { - resp.Body.Close() + if err := resp.Body.Close(); err != nil { + return fmt.Errorf("Error closing the response body: %v", err) + } } return err }) diff --git a/vendor/github.com/Azure/go-autorest/autorest/sender.go b/vendor/github.com/Azure/go-autorest/autorest/sender.go index a084318e2..b646a4832 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/sender.go +++ b/vendor/github.com/Azure/go-autorest/autorest/sender.go @@ -71,7 +71,7 @@ func SendWithSender(s Sender, r *http.Request, decorators ...SendDecorator) (*ht func AfterDelay(d time.Duration) SendDecorator { return func(s Sender) Sender { return SenderFunc(func(r *http.Request) (*http.Response, error) { - if DelayForBackoff(d, 1, r.Cancel) != nil { + if !DelayForBackoff(d, 1, r.Cancel) { return nil, fmt.Errorf("autorest: AfterDelay canceled before full delay") } return s.Do(r) @@ -223,15 +223,12 @@ func WithLogging(logger *log.Logger) SendDecorator { // DelayForBackoff invokes time.After for the supplied backoff duration raised to the power of // passed attempt (i.e., an exponential backoff delay). Backoff may be zero. The delay may be -// canceled by closing the passed channel. -func DelayForBackoff(backoff time.Duration, attempt int, cancel <-chan struct{}) error { - if cancel == nil { - cancel = make(chan struct{}) - } +// canceled by closing the passed channel. If terminated early, returns false. +func DelayForBackoff(backoff time.Duration, attempt int, cancel <-chan struct{}) bool { select { case <-time.After(time.Duration(math.Pow(float64(backoff), float64(attempt)))): + return true case <-cancel: - return fmt.Errorf("autorest: Delay canceled") + return false } - return nil }