From 5736742c3ea40bef93e9c484b49f9d249210ea7b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 19 Dec 2015 13:26:42 +0100 Subject: [PATCH] s3: Open() creates bucket if it does not exist --- backend/s3/s3.go | 15 +-------------- backend/s3_test.go | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 4687de387..f98942a8e 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -57,7 +57,7 @@ func getConfig(region, bucket string) minio.Config { return config } -// Open opens the S3 backend at bucket and region. +// Open opens the S3 backend at bucket and region. The bucket is created if it does not exist yet. func Open(regionname, bucketname string) (backend.Backend, error) { s3api, err := minio.New(getConfig(regionname, bucketname)) if err != nil { @@ -67,19 +67,6 @@ func Open(regionname, bucketname string) (backend.Backend, error) { be := &S3Backend{s3api: s3api, bucketname: bucketname} be.createConnections() - return be, nil -} - -// Create creates a new bucket in the given region and opens the backend. -func Create(regionname, bucketname string) (backend.Backend, error) { - s3api, err := minio.New(getConfig(regionname, bucketname)) - if err != nil { - return nil, err - } - - be := &S3Backend{s3api: s3api, bucketname: bucketname} - be.createConnections() - err = s3api.MakeBucket(bucketname, "") if err != nil { return nil, err diff --git a/backend/s3_test.go b/backend/s3_test.go index 4826769b2..0170f126e 100644 --- a/backend/s3_test.go +++ b/backend/s3_test.go @@ -12,7 +12,7 @@ type deleter interface { } func TestS3Backend(t *testing.T) { - be, err := s3.Create("127.0.0.1:9000", "restictestbucket") + be, err := s3.Open("127.0.0.1:9000", "restictestbucket") OK(t, err) testBackend(be, t)