From 38c00189069728afe2e21ee1be72db98f6b93b1c Mon Sep 17 00:00:00 2001 From: kayrus Date: Mon, 28 Jan 2019 17:54:58 +0100 Subject: [PATCH] Bump github.com/ncw/swift to v1.0.44 --- go.mod | 2 +- go.sum | 2 + vendor/github.com/ncw/swift/README.md | 3 +- vendor/github.com/ncw/swift/auth_v3.go | 114 +++++++++++++++++++------ vendor/github.com/ncw/swift/swift.go | 49 ++++++----- vendor/modules.txt | 2 +- 6 files changed, 123 insertions(+), 49 deletions(-) diff --git a/go.mod b/go.mod index 060d69da4..ae538aafe 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/kr/pretty v0.1.0 // indirect github.com/mattn/go-runewidth v0.0.3 // indirect github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2 - github.com/ncw/swift v1.0.43 + github.com/ncw/swift v1.0.44 github.com/nsf/termbox-go v0.0.0-20181027232701-60ab7e3d12ed github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd github.com/patrickmn/go-cache v2.1.0+incompatible diff --git a/go.sum b/go.sum index fa933ca1d..f2cc03136 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,8 @@ github.com/ncw/swift v1.0.42 h1:ztvRb6hs52IHOcaYt73f9lXYLIeIuWgdooRDhdyllGI= github.com/ncw/swift v1.0.42/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/ncw/swift v1.0.43 h1:TZn2l/bPV0CqG+/G5BFh/ROWnyX7dL2D0URaOjNQRsw= github.com/ncw/swift v1.0.43/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= +github.com/ncw/swift v1.0.44 h1:EKvOTvUxElbpDWqxsyVaVGvc2IfuOqQnRmjnR2AGhQ4= +github.com/ncw/swift v1.0.44/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/nsf/termbox-go v0.0.0-20181027232701-60ab7e3d12ed h1:bAVGG6B+R5qpSylrrA+BAMrzYkdAoiTaKPVxRB+4cyM= github.com/nsf/termbox-go v0.0.0-20181027232701-60ab7e3d12ed/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd h1:+iAPaTbi1gZpcpDwe/BW1fx7Xoesv69hLNGPheoyhBs= diff --git a/vendor/github.com/ncw/swift/README.md b/vendor/github.com/ncw/swift/README.md index a114762c3..f08c5b6f4 100644 --- a/vendor/github.com/ncw/swift/README.md +++ b/vendor/github.com/ncw/swift/README.md @@ -139,7 +139,7 @@ Contributors - Cezar Sa Espinola - Sam Gunaratne - Richard Scothern -- Michel Couillard +- Michel Couillard - Christopher Waldon - dennis - hag @@ -152,3 +152,4 @@ Contributors - Charles Hsu - Omar Ali - Andreas Andersen +- kayrus diff --git a/vendor/github.com/ncw/swift/auth_v3.go b/vendor/github.com/ncw/swift/auth_v3.go index 64dcabc9b..e8666ebed 100644 --- a/vendor/github.com/ncw/swift/auth_v3.go +++ b/vendor/github.com/ncw/swift/auth_v3.go @@ -3,14 +3,16 @@ package swift import ( "bytes" "encoding/json" + "fmt" "net/http" "strings" ) const ( - v3AuthMethodToken = "token" - v3AuthMethodPassword = "password" - v3CatalogTypeObjectStore = "object-store" + v3AuthMethodToken = "token" + v3AuthMethodPassword = "password" + v3AuthMethodApplicationCredential = "application_credential" + v3CatalogTypeObjectStore = "object-store" ) // V3 Authentication request @@ -19,9 +21,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,6 +66,13 @@ 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 { @@ -117,7 +127,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 +200,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"} + } } } } diff --git a/vendor/github.com/ncw/swift/swift.go b/vendor/github.com/ncw/swift/swift.go index 4f47be126..b81f9e5b9 100644 --- a/vendor/github.com/ncw/swift/swift.go +++ b/vendor/github.com/ncw/swift/swift.go @@ -96,26 +96,29 @@ 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 @@ -194,6 +197,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 +233,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"}, diff --git a/vendor/modules.txt b/vendor/modules.txt index d45c26255..a68a837fb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -103,7 +103,7 @@ github.com/kr/fs github.com/mattn/go-runewidth # github.com/ncw/go-acd v0.0.0-20171120105400-887eb06ab6a2 github.com/ncw/go-acd -# github.com/ncw/swift v1.0.43 +# github.com/ncw/swift v1.0.44 github.com/ncw/swift # github.com/nsf/termbox-go v0.0.0-20181027232701-60ab7e3d12ed github.com/nsf/termbox-go