mirror of
https://github.com/octoleo/restic.git
synced 2024-11-04 20:37:49 +00:00
s3: Open() creates bucket if it does not exist
This commit is contained in:
parent
248f991ad4
commit
5736742c3e
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user