From f812c2f2acbbd1fb5359a85864d931491eaf1e8f Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 18 Jan 2017 14:47:31 +0100 Subject: [PATCH] Update go-autorest library to v7.2.3 To include https://github.com/Azure/go-autorest/pull/107 Improves https://github.com/kubernetes/kubernetes/issues/35180 --- Godeps/Godeps.json | 20 +++++++++---------- .../Azure/go-autorest/autorest/azure/token.go | 2 +- .../Azure/go-autorest/autorest/error.go | 3 +++ .../Azure/go-autorest/autorest/responder.go | 13 +++++++++--- .../Azure/go-autorest/autorest/sender.go | 4 +++- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3bd35f9d781..b953b60d75d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -63,28 +63,28 @@ }, { "ImportPath": "github.com/Azure/go-autorest/autorest", - "Comment": "v7.2.2-8-ge0c77ec", - "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453" + "Comment": "v7.2.3", + "Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/azure", - "Comment": "v7.2.2-8-ge0c77ec", - "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453" + "Comment": "v7.2.3", + "Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/date", - "Comment": "v7.2.2-8-ge0c77ec", - "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453" + "Comment": "v7.2.3", + "Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/to", - "Comment": "v7.2.2-8-ge0c77ec", - "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453" + "Comment": "v7.2.3", + "Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/validation", - "Comment": "v7.2.2-8-ge0c77ec", - "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453" + "Comment": "v7.2.3", + "Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" }, { "ImportPath": "github.com/MakeNowJust/heredoc", diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/token.go b/vendor/github.com/Azure/go-autorest/autorest/azure/token.go index d2d38162cd7..cfcd030114c 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/token.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/token.go @@ -302,7 +302,7 @@ func (spt *ServicePrincipalToken) refreshInternal(resource string) error { var newToken Token err = autorest.Respond(resp, - autorest.WithErrorUnlessOK(), + autorest.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&newToken), autorest.ByClosing()) if err != nil { diff --git a/vendor/github.com/Azure/go-autorest/autorest/error.go b/vendor/github.com/Azure/go-autorest/autorest/error.go index 2e4fc79c10c..4bcb8f27b21 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/error.go +++ b/vendor/github.com/Azure/go-autorest/autorest/error.go @@ -28,6 +28,9 @@ type DetailedError struct { // Message is the error message. Message string + + // Service Error is the response body of failed API in bytes + ServiceError []byte } // NewError creates a new Error conforming object from the passed packageType, method, and diff --git a/vendor/github.com/Azure/go-autorest/autorest/responder.go b/vendor/github.com/Azure/go-autorest/autorest/responder.go index e377ad48afe..07cd7ef5cc8 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/responder.go +++ b/vendor/github.com/Azure/go-autorest/autorest/responder.go @@ -165,17 +165,24 @@ func ByUnmarshallingXML(v interface{}) RespondDecorator { } // WithErrorUnlessStatusCode returns a RespondDecorator that emits an error unless the response -// StatusCode is among the set passed. Since these are artificial errors, the response body -// may still require closing. +// StatusCode is among the set passed. On error, response body is fully read into a buffer and +// presented in the returned error, as well as in the response body. func WithErrorUnlessStatusCode(codes ...int) RespondDecorator { return func(r Responder) Responder { return ResponderFunc(func(resp *http.Response) error { err := r.Respond(resp) if err == nil && !ResponseHasStatusCode(resp, codes...) { - err = NewErrorWithResponse("autorest", "WithErrorUnlessStatusCode", resp, "%v %v failed with %s", + derr := NewErrorWithResponse("autorest", "WithErrorUnlessStatusCode", resp, "%v %v failed with %s", resp.Request.Method, resp.Request.URL, resp.Status) + if resp.Body != nil { + defer resp.Body.Close() + b, _ := ioutil.ReadAll(resp.Body) + derr.ServiceError = b + resp.Body = ioutil.NopCloser(bytes.NewReader(b)) + } + err = derr } 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 93e6489e9ce..a12f0f7ff55 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/sender.go +++ b/vendor/github.com/Azure/go-autorest/autorest/sender.go @@ -73,7 +73,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) { + if !DelayForBackoff(d, 0, r.Cancel) { return nil, fmt.Errorf("autorest: AfterDelay canceled before full delay") } return s.Do(r) @@ -257,6 +257,8 @@ func WithLogging(logger *log.Logger) SendDecorator { // passed attempt (i.e., an exponential backoff delay). Backoff duration is in seconds and can set // to zero for no delay. The delay may be canceled by closing the passed channel. If terminated early, // returns false. +// Note: Passing attempt 1 will result in doubling "backoff" duration. Treat this as a zero-based attempt +// count. func DelayForBackoff(backoff time.Duration, attempt int, cancel <-chan struct{}) bool { select { case <-time.After(time.Duration(backoff.Seconds()*math.Pow(2, float64(attempt))) * time.Second):