swift: update github.com/ncw/swift to v2.0.0

The update to v2 of the swift library introduces a context parameter
to each function. This required a lot of mostly mechanical changes
adding context parameters.

See: https://github.com/ncw/swift/issues/159
See: https://github.com/ncw/swift/issues/161
This commit is contained in:
Nick Craig-Wood 2021-01-22 17:23:51 +00:00
parent 1545ace8f2
commit bbe791a886
9 changed files with 88 additions and 87 deletions

View file

@ -1,10 +1,11 @@
package swift
import (
"context"
"net/http"
"time"
"github.com/ncw/swift"
"github.com/ncw/swift/v2"
)
// auth is an authenticator for swift. It overrides the StorageUrl
@ -28,19 +29,19 @@ func newAuth(parentAuth swift.Authenticator, storageURL string, authToken string
}
// Request creates an http.Request for the auth - return nil if not needed
func (a *auth) Request(c *swift.Connection) (*http.Request, error) {
func (a *auth) Request(ctx context.Context, c *swift.Connection) (*http.Request, error) {
if a.parentAuth == nil {
return nil, nil
}
return a.parentAuth.Request(c)
return a.parentAuth.Request(ctx, c)
}
// Response parses the http.Response
func (a *auth) Response(resp *http.Response) error {
func (a *auth) Response(ctx context.Context, resp *http.Response) error {
if a.parentAuth == nil {
return nil
}
return a.parentAuth.Response(resp)
return a.parentAuth.Response(ctx, resp)
}
// The public storage URL - set Internal to true to read