From a64e0922b9539e8fe09321c69b4bdcba9bfa9ad3 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 26 Aug 2018 15:03:19 +0100 Subject: [PATCH] vendor: update github.com/ncw/swift to fix server side copy bug --- Gopkg.lock | 6 +-- vendor/github.com/ncw/swift/.travis.yml | 27 +++++++------ vendor/github.com/ncw/swift/README.md | 39 ++++++++++--------- vendor/github.com/ncw/swift/swift.go | 11 +++++- vendor/github.com/ncw/swift/swift_test.go | 14 +++++++ .../github.com/ncw/swift/travis_realserver.sh | 2 +- 6 files changed, 63 insertions(+), 36 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 0e4edac06..19aab82df 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -250,12 +250,12 @@ revision = "887eb06ab6a255fbf5744b5812788e884078620a" [[projects]] - digest = "1:7a4827b2062a21ba644241bdec27959a5be2670f8aa4038ba14cfe2ce389e8d2" + digest = "1:e5b9ef2c82d0c904496a3fd6b14e34081df4d425d42d8e57d182ac3d8c93e98a" name = "github.com/ncw/swift" packages = ["."] pruneopts = "" - revision = "b2a7479cf26fa841ff90dd932d0221cb5c50782d" - version = "v1.0.39" + revision = "a0320860b16212c2b59b4912bb6508cda1d7cee6" + version = "v1.0.40" [[projects]] branch = "master" diff --git a/vendor/github.com/ncw/swift/.travis.yml b/vendor/github.com/ncw/swift/.travis.yml index 44a719e33..d064e46fe 100644 --- a/vendor/github.com/ncw/swift/.travis.yml +++ b/vendor/github.com/ncw/swift/.travis.yml @@ -2,26 +2,29 @@ language: go sudo: false go: - - 1.1.2 - - 1.2.2 - - 1.3.3 - - 1.4.3 - - 1.5.4 - - 1.6.4 - - 1.7.5 - - 1.8 + - 1.1.x + - 1.2.x + - 1.3.x + - 1.4.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - 1.10.x + - 1.11.x - master matrix: include: - - go: 1.8 + - go: 1.11.x env: TEST_REAL_SERVER=rackspace - - go: 1.8 + - go: 1.11.x env: TEST_REAL_SERVER=memset allow_failures: - - go: 1.8 + - go: 1.11.x env: TEST_REAL_SERVER=rackspace - - go: 1.8 + - go: 1.11.x env: TEST_REAL_SERVER=memset install: go test -i ./... script: diff --git a/vendor/github.com/ncw/swift/README.md b/vendor/github.com/ncw/swift/README.md index 5094a4675..1ffd1ccdb 100644 --- a/vendor/github.com/ncw/swift/README.md +++ b/vendor/github.com/ncw/swift/README.md @@ -26,26 +26,27 @@ See here for full package docs - http://godoc.org/github.com/ncw/swift Here is a short example from the docs +```go +import "github.com/ncw/swift" - import "github.com/ncw/swift" - - // Create a connection - c := swift.Connection{ - UserName: "user", - ApiKey: "key", - AuthUrl: "auth_url", - Domain: "domain", // Name of the domain (v3 auth only) - Tenant: "tenant", // Name of the tenant (v2 auth only) - } - // Authenticate - err := c.Authenticate() - if err != nil { - panic(err) - } - // List all the containers - containers, err := c.ContainerNames(nil) - fmt.Println(containers) - // etc... +// Create a connection +c := swift.Connection{ + UserName: "user", + ApiKey: "key", + AuthUrl: "auth_url", + Domain: "domain", // Name of the domain (v3 auth only) + Tenant: "tenant", // Name of the tenant (v2 auth only) +} +// Authenticate +err := c.Authenticate() +if err != nil { + panic(err) +} +// List all the containers +containers, err := c.ContainerNames(nil) +fmt.Println(containers) +// etc... +``` Additions --------- diff --git a/vendor/github.com/ncw/swift/swift.go b/vendor/github.com/ncw/swift/swift.go index 6c217fbc7..c8c28fa92 100644 --- a/vendor/github.com/ncw/swift/swift.go +++ b/vendor/github.com/ncw/swift/swift.go @@ -2079,6 +2079,15 @@ func (c *Connection) ObjectUpdate(container string, objectName string, h Headers return err } +// urlPathEscape escapes URL path the in string using URL escaping rules +// +// This mimics url.PathEscape which only available from go 1.8 +func urlPathEscape(in string) string { + var u url.URL + u.Path = in + return u.String() +} + // ObjectCopy does a server side copy of an object to a new position // // All metadata is preserved. If metadata is set in the headers then @@ -2091,7 +2100,7 @@ func (c *Connection) ObjectUpdate(container string, objectName string, h Headers func (c *Connection) ObjectCopy(srcContainer string, srcObjectName string, dstContainer string, dstObjectName string, h Headers) (headers Headers, err error) { // Meta stuff extraHeaders := map[string]string{ - "Destination": dstContainer + "/" + dstObjectName, + "Destination": urlPathEscape(dstContainer + "/" + dstObjectName), } for key, value := range h { extraHeaders[key] = value diff --git a/vendor/github.com/ncw/swift/swift_test.go b/vendor/github.com/ncw/swift/swift_test.go index b6c5682fb..839dbdd51 100644 --- a/vendor/github.com/ncw/swift/swift_test.go +++ b/vendor/github.com/ncw/swift/swift_test.go @@ -1479,6 +1479,20 @@ func TestObjectCopy(t *testing.T) { } } +func TestObjectCopyDifficultName(t *testing.T) { + c, rollback := makeConnectionWithObjectHeaders(t) + defer rollback() + const dest = OBJECT + "?param %30%31%32 £100" + _, err := c.ObjectCopy(CONTAINER, OBJECT, CONTAINER, dest, nil) + if err != nil { + t.Fatal(err) + } + err = c.ObjectDelete(CONTAINER, dest) + if err != nil { + t.Fatal(err) + } +} + func TestObjectCopyWithMetadata(t *testing.T) { c, rollback := makeConnectionWithObjectHeaders(t) defer rollback() diff --git a/vendor/github.com/ncw/swift/travis_realserver.sh b/vendor/github.com/ncw/swift/travis_realserver.sh index 90630e46a..970e94c0d 100755 --- a/vendor/github.com/ncw/swift/travis_realserver.sh +++ b/vendor/github.com/ncw/swift/travis_realserver.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -if [ ! "${TRAVIS_BRANCH}" = "master" ]; then +if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then exit 0 fi