update the golang compiler version and the versions of several dependencies
Signed-off-by: Tariq Ibrahim <tariq181290@gmail.com>
This commit is contained in:
parent
84f47e7bb3
commit
afe29bb697
209 changed files with 31657 additions and 7738 deletions
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
|
||||
|
||||
go:
|
||||
- 1.1.x
|
||||
- 1.2.x
|
||||
- 1.3.x
|
||||
- 1.4.x
|
||||
|
@ -13,18 +12,19 @@ go:
|
|||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.12.x
|
||||
- master
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- go: 1.11.x
|
||||
- go: 1.12.x
|
||||
env: TEST_REAL_SERVER=rackspace
|
||||
- go: 1.11.x
|
||||
- go: 1.12.x
|
||||
env: TEST_REAL_SERVER=memset
|
||||
allow_failures:
|
||||
- go: 1.11.x
|
||||
- go: 1.12.x
|
||||
env: TEST_REAL_SERVER=rackspace
|
||||
- go: 1.11.x
|
||||
- go: 1.12.x
|
||||
env: TEST_REAL_SERVER=memset
|
||||
install: go test -i ./...
|
||||
script:
|
||||
|
|
21
vendor/github.com/ncw/swift/README.md
generated
vendored
21
vendor/github.com/ncw/swift/README.md
generated
vendored
|
@ -127,17 +127,30 @@ Contributors
|
|||
- Paul Querna <pquerna@apache.org>
|
||||
- Livio Soares <liviobs@gmail.com>
|
||||
- thesyncim <thesyncim@gmail.com>
|
||||
- lsowen <lsowen@s1network.com>
|
||||
- lsowen <lsowen@s1network.com> <logan@s1network.com>
|
||||
- Sylvain Baubeau <sbaubeau@redhat.com>
|
||||
- Chris Kastorff <encryptio@gmail.com>
|
||||
- Dai HaoJun <haojun.dai@hp.com>
|
||||
- Hua Wang <wanghua.humble@gmail.com>
|
||||
- Fabian Ruff <fabian@progra.de>
|
||||
- Fabian Ruff <fabian@progra.de> <fabian.ruff@sap.com>
|
||||
- Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
|
||||
- Petr Kotek <petr.kotek@bigcommerce.com>
|
||||
- Stefan Majewsky <stefan.majewsky@sap.com>
|
||||
- Stefan Majewsky <stefan.majewsky@sap.com> <majewsky@gmx.net>
|
||||
- Cezar Sa Espinola <cezarsa@gmail.com>
|
||||
- Sam Gunaratne <samgzeit@gmail.com>
|
||||
- Richard Scothern <richard.scothern@gmail.com>
|
||||
- Michel Couillard <couillard.michel@voxlog.ca>
|
||||
- Michel Couillard <!--<couillard.michel@voxlog.ca>--> <michel.couillard@gmail.com>
|
||||
- Christopher Waldon <ckwaldon@us.ibm.com>
|
||||
- dennis <dai.haojun@gmail.com>
|
||||
- hag <hannes.georg@xing.com>
|
||||
- Alexander Neumann <alexander@bumpern.de>
|
||||
- eclipseo <30413512+eclipseo@users.noreply.github.com>
|
||||
- Yuri Per <yuri@acronis.com>
|
||||
- Falk Reimann <falk.reimann@sap.com>
|
||||
- Arthur Paim Arnold <arthurpaimarnold@gmail.com>
|
||||
- Bruno Michel <bmichel@menfin.info>
|
||||
- Charles Hsu <charles0126@gmail.com>
|
||||
- Omar Ali <omarali@users.noreply.github.com>
|
||||
- Andreas Andersen <andreas@softwaredesign.se>
|
||||
- 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/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)
|
||||
|
|
130
vendor/github.com/ncw/swift/auth_v3.go
generated
vendored
130
vendor/github.com/ncw/swift/auth_v3.go
generated
vendored
|
@ -3,14 +3,17 @@ package swift
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
v3AuthMethodToken = "token"
|
||||
v3AuthMethodPassword = "password"
|
||||
v3CatalogTypeObjectStore = "object-store"
|
||||
v3AuthMethodToken = "token"
|
||||
v3AuthMethodPassword = "password"
|
||||
v3AuthMethodApplicationCredential = "application_credential"
|
||||
v3CatalogTypeObjectStore = "object-store"
|
||||
)
|
||||
|
||||
// V3 Authentication request
|
||||
|
@ -19,9 +22,10 @@ const (
|
|||
type v3AuthRequest struct {
|
||||
Auth struct {
|
||||
Identity struct {
|
||||
Methods []string `json:"methods"`
|
||||
Password *v3AuthPassword `json:"password,omitempty"`
|
||||
Token *v3AuthToken `json:"token,omitempty"`
|
||||
Methods []string `json:"methods"`
|
||||
Password *v3AuthPassword `json:"password,omitempty"`
|
||||
Token *v3AuthToken `json:"token,omitempty"`
|
||||
ApplicationCredential *v3AuthApplicationCredential `json:"application_credential,omitempty"`
|
||||
} `json:"identity"`
|
||||
Scope *v3Scope `json:"scope,omitempty"`
|
||||
} `json:"auth"`
|
||||
|
@ -63,12 +67,20 @@ type v3AuthPassword struct {
|
|||
User v3User `json:"user"`
|
||||
}
|
||||
|
||||
type v3AuthApplicationCredential struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Secret string `json:"secret,omitempty"`
|
||||
User *v3User `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -117,7 +129,57 @@ func (auth *v3Auth) Request(c *Connection) (*http.Request, error) {
|
|||
|
||||
v3 := v3AuthRequest{}
|
||||
|
||||
if c.UserName == "" && c.UserId == "" {
|
||||
if (c.ApplicationCredentialId != "" || c.ApplicationCredentialName != "") && c.ApplicationCredentialSecret != "" {
|
||||
var user *v3User
|
||||
|
||||
if c.ApplicationCredentialId != "" {
|
||||
c.ApplicationCredentialName = ""
|
||||
user = &v3User{}
|
||||
}
|
||||
|
||||
if user == nil && c.UserId != "" {
|
||||
// UserID could be used without the domain information
|
||||
user = &v3User{
|
||||
Id: c.UserId,
|
||||
}
|
||||
}
|
||||
|
||||
if user == nil && c.UserName == "" {
|
||||
// Make sure that Username or UserID are provided
|
||||
return nil, fmt.Errorf("UserID or Name should be provided")
|
||||
}
|
||||
|
||||
if user == nil && c.DomainId != "" {
|
||||
user = &v3User{
|
||||
Name: c.UserName,
|
||||
Domain: &v3Domain{
|
||||
Id: c.DomainId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if user == nil && c.Domain != "" {
|
||||
user = &v3User{
|
||||
Name: c.UserName,
|
||||
Domain: &v3Domain{
|
||||
Name: c.Domain,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that DomainID or DomainName are provided among Username
|
||||
if user == nil {
|
||||
return nil, fmt.Errorf("DomainID or Domain should be provided")
|
||||
}
|
||||
|
||||
v3.Auth.Identity.Methods = []string{v3AuthMethodApplicationCredential}
|
||||
v3.Auth.Identity.ApplicationCredential = &v3AuthApplicationCredential{
|
||||
Id: c.ApplicationCredentialId,
|
||||
Name: c.ApplicationCredentialName,
|
||||
Secret: c.ApplicationCredentialSecret,
|
||||
User: user,
|
||||
}
|
||||
} else if c.UserName == "" && c.UserId == "" {
|
||||
v3.Auth.Identity.Methods = []string{v3AuthMethodToken}
|
||||
v3.Auth.Identity.Token = &v3AuthToken{Id: c.ApiKey}
|
||||
} else {
|
||||
|
@ -140,27 +202,29 @@ func (auth *v3Auth) Request(c *Connection) (*http.Request, error) {
|
|||
v3.Auth.Identity.Password.User.Domain = domain
|
||||
}
|
||||
|
||||
if c.TrustId != "" {
|
||||
v3.Auth.Scope = &v3Scope{Trust: &v3Trust{Id: c.TrustId}}
|
||||
} else if c.TenantId != "" || c.Tenant != "" {
|
||||
if v3.Auth.Identity.Methods[0] != v3AuthMethodApplicationCredential {
|
||||
if c.TrustId != "" {
|
||||
v3.Auth.Scope = &v3Scope{Trust: &v3Trust{Id: c.TrustId}}
|
||||
} else if c.TenantId != "" || c.Tenant != "" {
|
||||
|
||||
v3.Auth.Scope = &v3Scope{Project: &v3Project{}}
|
||||
v3.Auth.Scope = &v3Scope{Project: &v3Project{}}
|
||||
|
||||
if c.TenantId != "" {
|
||||
v3.Auth.Scope.Project.Id = c.TenantId
|
||||
} else if c.Tenant != "" {
|
||||
v3.Auth.Scope.Project.Name = c.Tenant
|
||||
switch {
|
||||
case c.TenantDomain != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: c.TenantDomain}
|
||||
case c.TenantDomainId != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Id: c.TenantDomainId}
|
||||
case c.Domain != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: c.Domain}
|
||||
case c.DomainId != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Id: c.DomainId}
|
||||
default:
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: "Default"}
|
||||
if c.TenantId != "" {
|
||||
v3.Auth.Scope.Project.Id = c.TenantId
|
||||
} else if c.Tenant != "" {
|
||||
v3.Auth.Scope.Project.Name = c.Tenant
|
||||
switch {
|
||||
case c.TenantDomain != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: c.TenantDomain}
|
||||
case c.TenantDomainId != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Id: c.TenantDomainId}
|
||||
case c.Domain != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: c.Domain}
|
||||
case c.DomainId != "":
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Id: c.DomainId}
|
||||
default:
|
||||
v3.Auth.Scope.Project.Domain = &v3Domain{Name: "Default"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,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 ""
|
||||
}
|
||||
|
|
23
vendor/github.com/ncw/swift/compatibility_1_6.go
generated
vendored
Normal file
23
vendor/github.com/ncw/swift/compatibility_1_6.go
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// +build go1.6
|
||||
|
||||
package swift
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const IS_AT_LEAST_GO_16 = true
|
||||
|
||||
func SetExpectContinueTimeout(tr *http.Transport, t time.Duration) {
|
||||
tr.ExpectContinueTimeout = t
|
||||
}
|
||||
|
||||
func AddExpectAndTransferEncoding(req *http.Request, hasContentLength bool) {
|
||||
if req.Body != nil {
|
||||
req.Header.Add("Expect", "100-continue")
|
||||
}
|
||||
if !hasContentLength {
|
||||
req.TransferEncoding = []string{"chunked"}
|
||||
}
|
||||
}
|
13
vendor/github.com/ncw/swift/compatibility_not_1_6.go
generated
vendored
Normal file
13
vendor/github.com/ncw/swift/compatibility_not_1_6.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// +build !go1.6
|
||||
|
||||
package swift
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const IS_AT_LEAST_GO_16 = false
|
||||
|
||||
func SetExpectContinueTimeout(tr *http.Transport, t time.Duration) {}
|
||||
func AddExpectAndTransferEncoding(req *http.Request, hasContentLength bool) {}
|
1
vendor/github.com/ncw/swift/go.mod
generated
vendored
Normal file
1
vendor/github.com/ncw/swift/go.mod
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module github.com/ncw/swift
|
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())
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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"])
|
||||
}
|
||||
|
||||
// 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
|
||||
// amongst others) for storing the modification time (as read using
|
||||
|
|
107
vendor/github.com/ncw/swift/swift.go
generated
vendored
107
vendor/github.com/ncw/swift/swift.go
generated
vendored
|
@ -96,29 +96,33 @@ const (
|
|||
type Connection struct {
|
||||
// Parameters - fill these in before calling Authenticate
|
||||
// They are all optional except UserName, ApiKey and AuthUrl
|
||||
Domain string // User's domain name
|
||||
DomainId string // User's domain Id
|
||||
UserName string // UserName for api
|
||||
UserId string // User Id
|
||||
ApiKey string // Key for api access
|
||||
AuthUrl string // Auth URL
|
||||
Retries int // Retries on error (default is 3)
|
||||
UserAgent string // Http User agent (default goswift/1.0)
|
||||
ConnectTimeout time.Duration // Connect channel timeout (default 10s)
|
||||
Timeout time.Duration // Data channel timeout (default 60s)
|
||||
Region string // Region to use eg "LON", "ORD" - default is use first region (v2,v3 auth only)
|
||||
AuthVersion int // Set to 1, 2 or 3 or leave at 0 for autodetect
|
||||
Internal bool // Set this to true to use the the internal / service network
|
||||
Tenant string // Name of the tenant (v2,v3 auth only)
|
||||
TenantId string // Id of the tenant (v2,v3 auth only)
|
||||
EndpointType EndpointType // Endpoint type (v2,v3 auth only) (default is public URL unless Internal is set)
|
||||
TenantDomain string // Name of the tenant's domain (v3 auth only), only needed if it differs from the user domain
|
||||
TenantDomainId string // Id of the tenant's domain (v3 auth only), only needed if it differs the from user domain
|
||||
TrustId string // Id of the trust (v3 auth only)
|
||||
Transport http.RoundTripper `json:"-" xml:"-"` // Optional specialised http.Transport (eg. for Google Appengine)
|
||||
Domain string // User's domain name
|
||||
DomainId string // User's domain Id
|
||||
UserName string // UserName for api
|
||||
UserId string // User Id
|
||||
ApiKey string // Key for api access
|
||||
ApplicationCredentialId string // Application Credential ID
|
||||
ApplicationCredentialName string // Application Credential Name
|
||||
ApplicationCredentialSecret string // Application Credential Secret
|
||||
AuthUrl string // Auth URL
|
||||
Retries int // Retries on error (default is 3)
|
||||
UserAgent string // Http User agent (default goswift/1.0)
|
||||
ConnectTimeout time.Duration // Connect channel timeout (default 10s)
|
||||
Timeout time.Duration // Data channel timeout (default 60s)
|
||||
Region string // Region to use eg "LON", "ORD" - default is use first region (v2,v3 auth only)
|
||||
AuthVersion int // Set to 1, 2 or 3 or leave at 0 for autodetect
|
||||
Internal bool // Set this to true to use the the internal / service network
|
||||
Tenant string // Name of the tenant (v2,v3 auth only)
|
||||
TenantId string // Id of the tenant (v2,v3 auth only)
|
||||
EndpointType EndpointType // Endpoint type (v2,v3 auth only) (default is public URL unless Internal is set)
|
||||
TenantDomain string // Name of the tenant's domain (v3 auth only), only needed if it differs from the user domain
|
||||
TenantDomainId string // Id of the tenant's domain (v3 auth only), only needed if it differs the from user domain
|
||||
TrustId string // Id of the trust (v3 auth only)
|
||||
Transport http.RoundTripper `json:"-" xml:"-"` // Optional specialised http.Transport (eg. for Google Appengine)
|
||||
// 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
|
||||
|
@ -194,6 +198,9 @@ func setFromEnv(param interface{}, name string) (err error) {
|
|||
// OS_USERNAME - UserName for api
|
||||
// OS_USER_ID - User Id
|
||||
// OS_PASSWORD - Key for api access
|
||||
// OS_APPLICATION_CREDENTIAL_ID - Application Credential ID
|
||||
// OS_APPLICATION_CREDENTIAL_NAME - Application Credential Name
|
||||
// OS_APPLICATION_CREDENTIAL_SECRET - Application Credential Secret
|
||||
// OS_USER_DOMAIN_NAME - User's domain name
|
||||
// OS_USER_DOMAIN_ID - User's domain Id
|
||||
// OS_PROJECT_NAME - Name of the project
|
||||
|
@ -227,6 +234,9 @@ func (c *Connection) ApplyEnvironment() (err error) {
|
|||
{&c.UserName, "OS_USERNAME"},
|
||||
{&c.UserId, "OS_USER_ID"},
|
||||
{&c.ApiKey, "OS_PASSWORD"},
|
||||
{&c.ApplicationCredentialId, "OS_APPLICATION_CREDENTIAL_ID"},
|
||||
{&c.ApplicationCredentialName, "OS_APPLICATION_CREDENTIAL_NAME"},
|
||||
{&c.ApplicationCredentialSecret, "OS_APPLICATION_CREDENTIAL_SECRET"},
|
||||
{&c.AuthUrl, "OS_AUTH_URL"},
|
||||
{&c.Retries, "GOSWIFT_RETRIES"},
|
||||
{&c.UserAgent, "GOSWIFT_USER_AGENT"},
|
||||
|
@ -298,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{
|
||||
|
@ -323,6 +334,7 @@ var (
|
|||
404: ObjectNotFound,
|
||||
413: TooLargeObject,
|
||||
422: ObjectCorrupted,
|
||||
429: TooManyRequests,
|
||||
498: RateLimit,
|
||||
}
|
||||
)
|
||||
|
@ -423,12 +435,15 @@ func (c *Connection) setDefaults() {
|
|||
c.Timeout = 60 * time.Second
|
||||
}
|
||||
if c.Transport == nil {
|
||||
c.Transport = &http.Transport{
|
||||
t := &http.Transport{
|
||||
// TLSClientConfig: &tls.Config{RootCAs: pool},
|
||||
// DisableCompression: true,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
MaxIdleConnsPerHost: 2048,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
// Half of linux's default open files limit (1024).
|
||||
MaxIdleConnsPerHost: 512,
|
||||
}
|
||||
SetExpectContinueTimeout(t, 5*time.Second)
|
||||
c.Transport = t
|
||||
}
|
||||
if c.client == nil {
|
||||
c.client = &http.Client{
|
||||
|
@ -507,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
|
||||
|
@ -568,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
|
||||
|
@ -708,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)
|
||||
}
|
||||
|
@ -720,13 +748,17 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
|
|||
}
|
||||
req.Header.Add("User-Agent", c.UserAgent)
|
||||
req.Header.Add("X-Auth-Token", authToken)
|
||||
|
||||
_, hasCL := p.Headers["Content-Length"]
|
||||
AddExpectAndTransferEncoding(req, hasCL)
|
||||
|
||||
resp, err = c.doTimeoutRequest(timer, req)
|
||||
if err != nil {
|
||||
if (p.Operation == "HEAD" || p.Operation == "GET") && retries > 0 {
|
||||
retries--
|
||||
continue
|
||||
}
|
||||
return nil, nil, err
|
||||
return
|
||||
}
|
||||
// Check to see if token has expired
|
||||
if resp.StatusCode == 401 && retries > 0 {
|
||||
|
@ -738,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
|
||||
|
@ -1013,7 +1044,8 @@ type Object struct {
|
|||
Bytes int64 `json:"bytes"` // size in bytes
|
||||
ServerLastModified string `json:"last_modified"` // Last modified time, eg '2011-06-30T08:20:47.736680' as a string supplied by the server
|
||||
LastModified time.Time // Last modified time converted to a time.Time
|
||||
Hash string `json:"hash"` // MD5 hash, eg "d41d8cd98f00b204e9800998ecf8427e"
|
||||
Hash string `json:"hash"` // MD5 hash, eg "d41d8cd98f00b204e9800998ecf8427e"
|
||||
SLOHash string `json:"slo_etag"` // MD5 hash of all segments' MD5 hash, eg "d41d8cd98f00b204e9800998ecf8427e"
|
||||
PseudoDirectory bool // Set when using delimiter to show that this directory object does not really exist
|
||||
SubDir string `json:"subdir"` // returned only when using delimiter to mark "pseudo directories"
|
||||
ObjectType ObjectType // type of this object
|
||||
|
@ -1065,6 +1097,9 @@ func (c *Connection) Objects(container string, opts *ObjectsOpts) ([]Object, err
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
if object.SLOHash != "" {
|
||||
object.ObjectType = StaticLargeObjectType
|
||||
}
|
||||
}
|
||||
return objects, err
|
||||
}
|
||||
|
@ -1895,6 +1930,10 @@ func (c *Connection) doBulkDelete(objects []string) (result BulkDeleteResult, er
|
|||
// * http://docs.openstack.org/trunk/openstack-object-storage/admin/content/object-storage-bulk-delete.html
|
||||
// * http://docs.rackspace.com/files/api/v1/cf-devguide/content/Bulk_Delete-d1e2338.html
|
||||
func (c *Connection) BulkDelete(container string, objectNames []string) (result BulkDeleteResult, err error) {
|
||||
if len(objectNames) == 0 {
|
||||
result.Errors = make(map[string]error)
|
||||
return
|
||||
}
|
||||
fullPaths := make([]string, len(objectNames))
|
||||
for i, name := range objectNames {
|
||||
fullPaths[i] = fmt.Sprintf("/%s/%s", container, name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue