forked from TrueCloudLab/rclone
vendor: update github.com/ncw/swift to bring in Expires changes
This commit is contained in:
parent
bb80586473
commit
595fea757d
9 changed files with 55 additions and 13 deletions
2
go.mod
2
go.mod
|
@ -28,7 +28,7 @@ require (
|
||||||
github.com/kr/fs v0.1.0 // indirect
|
github.com/kr/fs v0.1.0 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.4
|
github.com/mattn/go-runewidth v0.0.4
|
||||||
github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2
|
github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2
|
||||||
github.com/ncw/swift v1.0.44
|
github.com/ncw/swift v1.0.46
|
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
|
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
|
||||||
github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
|
github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -109,6 +109,8 @@ github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2 h1:VlXvEx6JbFp7F9iz92zX
|
||||||
github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2/go.mod h1:MLIrzg7gp/kzVBxRE1olT7CWYMCklcUWU+ekoxOD9x0=
|
github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2/go.mod h1:MLIrzg7gp/kzVBxRE1olT7CWYMCklcUWU+ekoxOD9x0=
|
||||||
github.com/ncw/swift v1.0.44 h1:EKvOTvUxElbpDWqxsyVaVGvc2IfuOqQnRmjnR2AGhQ4=
|
github.com/ncw/swift v1.0.44 h1:EKvOTvUxElbpDWqxsyVaVGvc2IfuOqQnRmjnR2AGhQ4=
|
||||||
github.com/ncw/swift v1.0.44/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
|
github.com/ncw/swift v1.0.44/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
|
||||||
|
github.com/ncw/swift v1.0.46 h1:ewnoFKEI9f2LT+gqmeeiJ1SCzOBDTcK3JF1XziR85QQ=
|
||||||
|
github.com/ncw/swift v1.0.46/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
|
||||||
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
||||||
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
|
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
|
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
|
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
|
||||||
|
|
10
vendor/github.com/ncw/swift/.travis.yml
generated
vendored
10
vendor/github.com/ncw/swift/.travis.yml
generated
vendored
|
@ -2,7 +2,6 @@ language: go
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.1.x
|
|
||||||
- 1.2.x
|
- 1.2.x
|
||||||
- 1.3.x
|
- 1.3.x
|
||||||
- 1.4.x
|
- 1.4.x
|
||||||
|
@ -13,18 +12,19 @@ go:
|
||||||
- 1.9.x
|
- 1.9.x
|
||||||
- 1.10.x
|
- 1.10.x
|
||||||
- 1.11.x
|
- 1.11.x
|
||||||
|
- 1.12.x
|
||||||
- master
|
- master
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- go: 1.11.x
|
- go: 1.12.x
|
||||||
env: TEST_REAL_SERVER=rackspace
|
env: TEST_REAL_SERVER=rackspace
|
||||||
- go: 1.11.x
|
- go: 1.12.x
|
||||||
env: TEST_REAL_SERVER=memset
|
env: TEST_REAL_SERVER=memset
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- go: 1.11.x
|
- go: 1.12.x
|
||||||
env: TEST_REAL_SERVER=rackspace
|
env: TEST_REAL_SERVER=rackspace
|
||||||
- go: 1.11.x
|
- go: 1.12.x
|
||||||
env: TEST_REAL_SERVER=memset
|
env: TEST_REAL_SERVER=memset
|
||||||
install: go test -i ./...
|
install: go test -i ./...
|
||||||
script:
|
script:
|
||||||
|
|
1
vendor/github.com/ncw/swift/README.md
generated
vendored
1
vendor/github.com/ncw/swift/README.md
generated
vendored
|
@ -153,3 +153,4 @@ Contributors
|
||||||
- Omar Ali <omarali@users.noreply.github.com>
|
- Omar Ali <omarali@users.noreply.github.com>
|
||||||
- Andreas Andersen <andreas@softwaredesign.se>
|
- Andreas Andersen <andreas@softwaredesign.se>
|
||||||
- kayrus <kay.diam@gmail.com>
|
- kayrus <kay.diam@gmail.com>
|
||||||
|
- CodeLingo Bot <bot@codelingo.io>
|
||||||
|
|
15
vendor/github.com/ncw/swift/auth.go
generated
vendored
15
vendor/github.com/ncw/swift/auth.go
generated
vendored
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Auth defines the operations needed to authenticate with swift
|
// Auth defines the operations needed to authenticate with swift
|
||||||
|
@ -25,6 +26,11 @@ type Authenticator interface {
|
||||||
CdnUrl() string
|
CdnUrl() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expireser is an optional interface to read the expiration time of the token
|
||||||
|
type Expireser interface {
|
||||||
|
Expires() time.Time
|
||||||
|
}
|
||||||
|
|
||||||
type CustomEndpointAuthenticator interface {
|
type CustomEndpointAuthenticator interface {
|
||||||
StorageUrlForEndpoint(endpointType EndpointType) string
|
StorageUrlForEndpoint(endpointType EndpointType) string
|
||||||
}
|
}
|
||||||
|
@ -240,6 +246,15 @@ func (auth *v2Auth) Token() string {
|
||||||
return auth.Auth.Access.Token.Id
|
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
|
// v2 Authentication - read cdn url
|
||||||
func (auth *v2Auth) CdnUrl() string {
|
func (auth *v2Auth) CdnUrl() string {
|
||||||
return auth.endpointUrl("rax:object-cdn", EndpointTypePublic)
|
return auth.endpointUrl("rax:object-cdn", EndpointTypePublic)
|
||||||
|
|
16
vendor/github.com/ncw/swift/auth_v3.go
generated
vendored
16
vendor/github.com/ncw/swift/auth_v3.go
generated
vendored
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -76,9 +77,10 @@ type v3AuthApplicationCredential struct {
|
||||||
// V3 Authentication response
|
// V3 Authentication response
|
||||||
type v3AuthResponse struct {
|
type v3AuthResponse struct {
|
||||||
Token struct {
|
Token struct {
|
||||||
Expires_At, Issued_At string
|
ExpiresAt string `json:"expires_at"`
|
||||||
Methods []string
|
IssuedAt string `json:"issued_at"`
|
||||||
Roles []struct {
|
Methods []string
|
||||||
|
Roles []struct {
|
||||||
Id, Name string
|
Id, Name string
|
||||||
Links struct {
|
Links struct {
|
||||||
Self string
|
Self string
|
||||||
|
@ -285,6 +287,14 @@ func (auth *v3Auth) Token() string {
|
||||||
return auth.Headers.Get("X-Subject-Token")
|
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 {
|
func (auth *v3Auth) CdnUrl() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
4
vendor/github.com/ncw/swift/meta.go
generated
vendored
4
vendor/github.com/ncw/swift/meta.go
generated
vendored
|
@ -151,7 +151,7 @@ func TimeToFloatString(t time.Time) string {
|
||||||
return nsToFloatString(t.UnixNano())
|
return nsToFloatString(t.UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read a modification time (mtime) from a Metadata object
|
// GetModTime reads a modification time (mtime) from a Metadata object
|
||||||
//
|
//
|
||||||
// This is a defacto standard (used in the official python-swiftclient
|
// This is a defacto standard (used in the official python-swiftclient
|
||||||
// amongst others) for storing the modification time (as read using
|
// amongst others) for storing the modification time (as read using
|
||||||
|
@ -163,7 +163,7 @@ func (m Metadata) GetModTime() (t time.Time, err error) {
|
||||||
return FloatStringToTime(m["mtime"])
|
return FloatStringToTime(m["mtime"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write an modification time (mtime) to a Metadata object
|
// SetModTime writes an modification time (mtime) to a Metadata object
|
||||||
//
|
//
|
||||||
// This is a defacto standard (used in the official python-swiftclient
|
// This is a defacto standard (used in the official python-swiftclient
|
||||||
// amongst others) for storing the modification time (as read using
|
// amongst others) for storing the modification time (as read using
|
||||||
|
|
16
vendor/github.com/ncw/swift/swift.go
generated
vendored
16
vendor/github.com/ncw/swift/swift.go
generated
vendored
|
@ -122,6 +122,7 @@ type Connection struct {
|
||||||
// These are filled in after Authenticate is called as are the defaults for above
|
// These are filled in after Authenticate is called as are the defaults for above
|
||||||
StorageUrl string
|
StorageUrl string
|
||||||
AuthToken string
|
AuthToken string
|
||||||
|
Expires time.Time // time the token expires, may be Zero if unknown
|
||||||
client *http.Client
|
client *http.Client
|
||||||
Auth Authenticator `json:"-" xml:"-"` // the current authenticator
|
Auth Authenticator `json:"-" xml:"-"` // the current authenticator
|
||||||
authLock sync.Mutex // lock when R/W StorageUrl, AuthToken, Auth
|
authLock sync.Mutex // lock when R/W StorageUrl, AuthToken, Auth
|
||||||
|
@ -519,6 +520,12 @@ again:
|
||||||
c.StorageUrl = c.Auth.StorageUrl(c.Internal)
|
c.StorageUrl = c.Auth.StorageUrl(c.Internal)
|
||||||
}
|
}
|
||||||
c.AuthToken = c.Auth.Token()
|
c.AuthToken = c.Auth.Token()
|
||||||
|
if do, ok := c.Auth.(Expireser); ok {
|
||||||
|
c.Expires = do.Expires()
|
||||||
|
} else {
|
||||||
|
c.Expires = time.Time{}
|
||||||
|
}
|
||||||
|
|
||||||
if !c.authenticated() {
|
if !c.authenticated() {
|
||||||
err = newError(0, "Response didn't have storage url and auth token")
|
err = newError(0, "Response didn't have storage url and auth token")
|
||||||
return
|
return
|
||||||
|
@ -580,7 +587,14 @@ func (c *Connection) Authenticated() bool {
|
||||||
//
|
//
|
||||||
// Call with authLock held
|
// Call with authLock held
|
||||||
func (c *Connection) authenticated() bool {
|
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
|
// SwiftInfo contains the JSON object returned by Swift when the /info
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -108,7 +108,7 @@ github.com/kr/fs
|
||||||
github.com/mattn/go-runewidth
|
github.com/mattn/go-runewidth
|
||||||
# github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2
|
# github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2
|
||||||
github.com/ncw/go-acd
|
github.com/ncw/go-acd
|
||||||
# github.com/ncw/swift v1.0.44
|
# github.com/ncw/swift v1.0.46
|
||||||
github.com/ncw/swift
|
github.com/ncw/swift
|
||||||
# github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
|
# github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
|
||||||
github.com/nsf/termbox-go
|
github.com/nsf/termbox-go
|
||||||
|
|
Loading…
Reference in a new issue