diff --git a/vendor/github.com/minio/minio-go/api-put-bucket.go b/vendor/github.com/minio/minio-go/api-put-bucket.go index e68ab824..986099e3 100644 --- a/vendor/github.com/minio/minio-go/api-put-bucket.go +++ b/vendor/github.com/minio/minio-go/api-put-bucket.go @@ -91,19 +91,14 @@ func (c Client) makeBucketRequest(bucketName string, acl BucketACL, location str return nil, ErrInvalidArgument("Unrecognized ACL " + acl.String()) } - // Set get bucket location always as path style. + // In case of Amazon S3. The make bucket issued on already + // existing bucket would fail with 'AuthorizationMalformed' error + // if virtual style is used. So we default to 'path style' as that + // is the preferred method here. The final location of the + // 'bucket' is provided through XML LocationConstraint data with + // the request. targetURL := *c.endpointURL - if bucketName != "" { - // If endpoint supports virtual host style use that always. - // Currently only S3 and Google Cloud Storage would support this. - if isVirtualHostSupported(c.endpointURL, bucketName) { - targetURL.Host = bucketName + "." + c.endpointURL.Host - targetURL.Path = "/" - } else { - // If not fall back to using path style. - targetURL.Path = "/" + bucketName + "/" - } - } + targetURL.Path = "/" + bucketName + "/" // get a new HTTP request for the method. req, err := http.NewRequest("PUT", targetURL.String(), nil) diff --git a/vendor/github.com/minio/minio-go/api_functional_v2_test.go b/vendor/github.com/minio/minio-go/api_functional_v2_test.go index ba0d3bcd..990e0281 100644 --- a/vendor/github.com/minio/minio-go/api_functional_v2_test.go +++ b/vendor/github.com/minio/minio-go/api_functional_v2_test.go @@ -31,6 +31,53 @@ import ( "github.com/minio/minio-go" ) +// Tests bucket re-create errors. +func TestMakeBucketErrorV2(t *testing.T) { + if testing.Short() { + t.Skip("skipping functional tests for short runs") + } + + // Seed random based on current time. + rand.Seed(time.Now().Unix()) + + // Instantiate new minio client object. + c, err := minio.NewV2( + "s3.amazonaws.com", + os.Getenv("ACCESS_KEY"), + os.Getenv("SECRET_KEY"), + false, + ) + if err != nil { + t.Fatal("Error:", err) + } + + // Enable tracing, write to stderr. + // c.TraceOn(os.Stderr) + + // Set user agent. + c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0") + + // Generate a new random bucket name. + bucketName := randString(60, rand.NewSource(time.Now().UnixNano())) + + // Make a new bucket in 'eu-west-1'. + if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err != nil { + t.Fatal("Error:", err, bucketName) + } + if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err == nil { + t.Fatal("Error: make bucket should should fail for", bucketName) + } + // Verify valid error response from server. + if minio.ToErrorResponse(err).Code != "BucketAlreadyExists" && + minio.ToErrorResponse(err).Code != "BucketAlreadyOwnedByYou" { + t.Fatal("Error: Invalid error returned by server", err) + } + if err = c.RemoveBucket(bucketName); err != nil { + t.Fatal("Error:", err, bucketName) + } +} + +// Test get object reader to not throw error on being closed twice. func TestGetObjectClosedTwiceV2(t *testing.T) { if testing.Short() { t.Skip("skipping functional tests for short runs") @@ -39,8 +86,8 @@ func TestGetObjectClosedTwiceV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -124,7 +171,7 @@ func TestRemovePartiallyUploadedV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -191,8 +238,8 @@ func TestResumbalePutObjectV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -302,8 +349,8 @@ func TestResumableFPutObjectV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -379,8 +426,8 @@ func TestMakeBucketRegionsV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -400,7 +447,7 @@ func TestMakeBucketRegionsV2(t *testing.T) { bucketName := randString(60, rand.NewSource(time.Now().UnixNano())) // Make a new bucket in 'eu-central-1'. - if err = c.MakeBucket(bucketName, "private", "eu-central-1"); err != nil { + if err = c.MakeBucket(bucketName, "private", "eu-west-1"); err != nil { t.Fatal("Error:", err, bucketName) } @@ -430,8 +477,8 @@ func TestResumablePutObjectV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -494,8 +541,8 @@ func TestGetObjectReadSeekFunctionalV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -608,8 +655,8 @@ func TestGetObjectReadAtFunctionalV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. - c, err := minio.New( + // Instantiate new minio client object. + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), @@ -750,7 +797,7 @@ func TestFunctionalV2(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - c, err := minio.New( + c, err := minio.NewV2( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), diff --git a/vendor/github.com/minio/minio-go/api_functional_v4_test.go b/vendor/github.com/minio/minio-go/api_functional_v4_test.go index ba7b7614..5e88c612 100644 --- a/vendor/github.com/minio/minio-go/api_functional_v4_test.go +++ b/vendor/github.com/minio/minio-go/api_functional_v4_test.go @@ -55,6 +55,52 @@ func randString(n int, src rand.Source) string { return string(b[0:30]) } +// Tests bucket re-create errors. +func TestMakeBucketError(t *testing.T) { + if testing.Short() { + t.Skip("skipping functional tests for short runs") + } + + // Seed random based on current time. + rand.Seed(time.Now().Unix()) + + // Instantiate new minio client object. + c, err := minio.New( + "s3.amazonaws.com", + os.Getenv("ACCESS_KEY"), + os.Getenv("SECRET_KEY"), + false, + ) + if err != nil { + t.Fatal("Error:", err) + } + + // Enable tracing, write to stderr. + // c.TraceOn(os.Stderr) + + // Set user agent. + c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0") + + // Generate a new random bucket name. + bucketName := randString(60, rand.NewSource(time.Now().UnixNano())) + + // Make a new bucket in 'eu-central-1'. + if err = c.MakeBucket(bucketName, "private", "eu-central-1"); err != nil { + t.Fatal("Error:", err, bucketName) + } + if err = c.MakeBucket(bucketName, "private", "eu-central-1"); err == nil { + t.Fatal("Error: make bucket should should fail for", bucketName) + } + // Verify valid error response from server. + if minio.ToErrorResponse(err).Code != "BucketAlreadyExists" && + minio.ToErrorResponse(err).Code != "BucketAlreadyOwnedByYou" { + t.Fatal("Error: Invalid error returned by server", err) + } + if err = c.RemoveBucket(bucketName); err != nil { + t.Fatal("Error:", err, bucketName) + } +} + // Tests various bucket supported formats. func TestMakeBucketRegions(t *testing.T) { if testing.Short() { @@ -64,7 +110,7 @@ func TestMakeBucketRegions(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -115,7 +161,7 @@ func TestGetObjectClosedTwice(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -200,7 +246,7 @@ func TestRemovePartiallyUploaded(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -236,7 +282,7 @@ func TestRemovePartiallyUploaded(t *testing.T) { } i++ } - err = writer.CloseWithError(errors.New("Proactively closed to be verified later.")) + err := writer.CloseWithError(errors.New("Proactively closed to be verified later.")) if err != nil { t.Fatal("Error:", err) } @@ -270,7 +316,7 @@ func TestResumbalePutObject(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -380,7 +426,7 @@ func TestResumableFPutObject(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -460,7 +506,7 @@ func TestResumablePutObject(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -524,7 +570,7 @@ func TestGetObjectReadSeekFunctional(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), @@ -638,7 +684,7 @@ func TestGetObjectReadAtFunctional(t *testing.T) { // Seed random based on current time. rand.Seed(time.Now().Unix()) - // Connect and make sure bucket exists. + // Instantiate new minio client object. c, err := minio.New( "s3.amazonaws.com", os.Getenv("ACCESS_KEY"), diff --git a/vendor/github.com/minio/minio-go/request-signature-v2.go b/vendor/github.com/minio/minio-go/request-signature-v2.go index 9458c4fd..aa0fc9f9 100644 --- a/vendor/github.com/minio/minio-go/request-signature-v2.go +++ b/vendor/github.com/minio/minio-go/request-signature-v2.go @@ -24,6 +24,7 @@ import ( "fmt" "net/http" "net/url" + "path/filepath" "sort" "strconv" "strings" @@ -38,8 +39,11 @@ const ( // Encode input URL path to URL encoded path. func encodeURL2Path(u *url.URL) (path string) { // Encode URL path. - if strings.HasSuffix(u.Host, ".s3.amazonaws.com") { - path = "/" + strings.TrimSuffix(u.Host, ".s3.amazonaws.com") + if isS3, _ := filepath.Match("*.s3*.amazonaws.com", u.Host); isS3 { + hostSplits := strings.SplitN(u.Host, ".", 4) + // First element is the bucket name. + bucketName := hostSplits[0] + path = "/" + bucketName path += u.Path path = urlEncodePath(path) return diff --git a/vendor/vendor.json b/vendor/vendor.json index e02bd285..608d6304 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -29,8 +29,8 @@ }, { "path": "github.com/minio/minio-go", - "revision": "65e5154d5edc3c1c1279d71ab595cc4a6bb94b1a", - "revisionTime": "2016-01-25T00:19:13-08:00" + "revision": "da044a0509a9a9e667e8cc838a7313b0a8ba2710", + "revisionTime": "2016-01-25T16:31:01-08:00" }, { "path": "github.com/minio/minio-xl/pkg/atomic",