Update dependencies

This commit is contained in:
Alexander Neumann
2019-04-24 12:32:52 +02:00
parent c7762453cf
commit ca8c3b4fd5
286 changed files with 28160 additions and 15888 deletions

15
vendor/github.com/ncw/swift/auth.go generated vendored
View File

@@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
)
// Auth defines the operations needed to authenticate with swift
@@ -25,6 +26,11 @@ type Authenticator interface {
CdnUrl() string
}
// Expireser is an optional interface to read the expiration time of the token
type Expireser interface {
Expires() time.Time
}
type CustomEndpointAuthenticator interface {
StorageUrlForEndpoint(endpointType EndpointType) string
}
@@ -240,6 +246,15 @@ func (auth *v2Auth) Token() string {
return auth.Auth.Access.Token.Id
}
// v2 Authentication - read expires
func (auth *v2Auth) Expires() time.Time {
t, err := time.Parse(time.RFC3339, auth.Auth.Access.Token.Expires)
if err != nil {
return time.Time{} // return Zero if not parsed
}
return t
}
// v2 Authentication - read cdn url
func (auth *v2Auth) CdnUrl() string {
return auth.endpointUrl("rax:object-cdn", EndpointTypePublic)

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"strings"
"time"
)
const (
@@ -76,9 +77,10 @@ type v3AuthApplicationCredential struct {
// V3 Authentication response
type v3AuthResponse struct {
Token struct {
Expires_At, Issued_At string
Methods []string
Roles []struct {
ExpiresAt string `json:"expires_at"`
IssuedAt string `json:"issued_at"`
Methods []string
Roles []struct {
Id, Name string
Links struct {
Self string
@@ -285,6 +287,14 @@ func (auth *v3Auth) Token() string {
return auth.Headers.Get("X-Subject-Token")
}
func (auth *v3Auth) Expires() time.Time {
t, err := time.Parse(time.RFC3339, auth.Auth.Token.ExpiresAt)
if err != nil {
return time.Time{} // return Zero if not parsed
}
return t
}
func (auth *v3Auth) CdnUrl() string {
return ""
}

View File

@@ -14,7 +14,9 @@ func SetExpectContinueTimeout(tr *http.Transport, t time.Duration) {
}
func AddExpectAndTransferEncoding(req *http.Request, hasContentLength bool) {
req.Header.Add("Expect", "100-continue")
if req.Body != nil {
req.Header.Add("Expect", "100-continue")
}
if !hasContentLength {
req.TransferEncoding = []string{"chunked"}
}

35
vendor/github.com/ncw/swift/swift.go generated vendored
View File

@@ -122,6 +122,7 @@ type Connection struct {
// These are filled in after Authenticate is called as are the defaults for above
StorageUrl string
AuthToken string
Expires time.Time // time the token expires, may be Zero if unknown
client *http.Client
Auth Authenticator `json:"-" xml:"-"` // the current authenticator
authLock sync.Mutex // lock when R/W StorageUrl, AuthToken, Auth
@@ -307,6 +308,7 @@ var (
Forbidden = newError(403, "Operation forbidden")
TooLargeObject = newError(413, "Too Large Object")
RateLimit = newError(498, "Rate Limit")
TooManyRequests = newError(429, "TooManyRequests")
// Mappings for authentication errors
authErrorMap = errorMap{
@@ -332,6 +334,7 @@ var (
404: ObjectNotFound,
413: TooLargeObject,
422: ObjectCorrupted,
429: TooManyRequests,
498: RateLimit,
}
)
@@ -519,6 +522,12 @@ again:
c.StorageUrl = c.Auth.StorageUrl(c.Internal)
}
c.AuthToken = c.Auth.Token()
if do, ok := c.Auth.(Expireser); ok {
c.Expires = do.Expires()
} else {
c.Expires = time.Time{}
}
if !c.authenticated() {
err = newError(0, "Response didn't have storage url and auth token")
return
@@ -580,7 +589,14 @@ func (c *Connection) Authenticated() bool {
//
// Call with authLock held
func (c *Connection) authenticated() bool {
return c.StorageUrl != "" && c.AuthToken != ""
if c.StorageUrl == "" || c.AuthToken == "" {
return false
}
if c.Expires.IsZero() {
return true
}
timeUntilExpiry := c.Expires.Sub(time.Now())
return timeUntilExpiry >= 60*time.Second
}
// SwiftInfo contains the JSON object returned by Swift when the /info
@@ -720,11 +736,11 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
for k, v := range p.Headers {
// Set ContentLength in req if the user passed it in in the headers
if k == "Content-Length" {
contentLength, err := strconv.ParseInt(v, 10, 64)
req.ContentLength, err = strconv.ParseInt(v, 10, 64)
if err != nil {
return nil, nil, fmt.Errorf("Invalid %q header %q: %v", k, v, err)
err = fmt.Errorf("Invalid %q header %q: %v", k, v, err)
return
}
req.ContentLength = contentLength
} else {
req.Header.Add(k, v)
}
@@ -742,7 +758,7 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
retries--
continue
}
return nil, nil, err
return
}
// Check to see if token has expired
if resp.StatusCode == 401 && retries > 0 {
@@ -754,15 +770,14 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
}
}
if err = c.parseHeaders(resp, p.ErrorMap); err != nil {
return nil, nil, err
}
headers = readHeaders(resp)
if err = c.parseHeaders(resp, p.ErrorMap); err != nil {
return
}
if p.NoResponse {
var err error
drainAndClose(resp.Body, &err)
if err != nil {
return nil, nil, err
return
}
} else {
// Cancel the request on timeout