mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
Fix some donut TODO's regarding bucket created date
This commit is contained in:
parent
39dac2afac
commit
ad60b97d52
@ -31,7 +31,7 @@ type ObjectStorage interface {
|
|||||||
// Storage service Operations
|
// Storage service Operations
|
||||||
GetBucketMetadata(bucket string) (map[string]string, error)
|
GetBucketMetadata(bucket string) (map[string]string, error)
|
||||||
SetBucketMetadata(bucket string, metadata map[string]string) error
|
SetBucketMetadata(bucket string, metadata map[string]string) error
|
||||||
ListBuckets() ([]string, error)
|
ListBuckets() (map[string]map[string]string, error)
|
||||||
MakeBucket(bucket, acl string) error
|
MakeBucket(bucket, acl string) error
|
||||||
|
|
||||||
// Bucket Operations
|
// Bucket Operations
|
||||||
|
@ -62,9 +62,9 @@ func (s *MySuite) TestEmptyDonut(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
// check donut is empty
|
// check donut is empty
|
||||||
buckets, err := donut.ListBuckets()
|
metadata, err := donut.ListBuckets()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(buckets, IsNil)
|
c.Assert(len(metadata), Equals, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test make bucket without name
|
// test make bucket without name
|
||||||
@ -112,7 +112,8 @@ func (s *MySuite) TestMakeBucketAndList(c *C) {
|
|||||||
// check bucket exists
|
// check bucket exists
|
||||||
buckets, err := donut.ListBuckets()
|
buckets, err := donut.ListBuckets()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(buckets, DeepEquals, []string{"foo"})
|
c.Assert(len(buckets), Equals, 1)
|
||||||
|
c.Assert(buckets["foo"]["acl"], Equals, "private")
|
||||||
}
|
}
|
||||||
|
|
||||||
// test re-create bucket
|
// test re-create bucket
|
||||||
@ -145,14 +146,19 @@ func (s *MySuite) TestCreateMultipleBucketsAndList(c *C) {
|
|||||||
|
|
||||||
buckets, err := donut.ListBuckets()
|
buckets, err := donut.ListBuckets()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(buckets, DeepEquals, []string{"bar", "foo"})
|
|
||||||
|
_, ok := buckets["foo"]
|
||||||
|
c.Assert(ok, Equals, true)
|
||||||
|
_, ok = buckets["bar"]
|
||||||
|
c.Assert(ok, Equals, true)
|
||||||
|
|
||||||
err = donut.MakeBucket("foobar", "private")
|
err = donut.MakeBucket("foobar", "private")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
buckets, err = donut.ListBuckets()
|
buckets, err = donut.ListBuckets()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(buckets, DeepEquals, []string{"bar", "foo", "foobar"})
|
_, ok = buckets["foobar"]
|
||||||
|
c.Assert(ok, Equals, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test object create without bucket
|
// test object create without bucket
|
||||||
|
@ -19,7 +19,6 @@ package donut
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -69,25 +68,20 @@ func (d donut) SetBucketMetadata(bucket string, bucketMetadata map[string]string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBuckets - return list of buckets
|
// ListBuckets - return list of buckets
|
||||||
func (d donut) ListBuckets() (results []string, err error) {
|
func (d donut) ListBuckets() (metadata map[string]map[string]string, err error) {
|
||||||
err = d.getDonutBuckets()
|
err = d.getDonutBuckets()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, iodine.New(err, nil)
|
return nil, iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
metadata, err := d.getDonutBucketMetadata()
|
dummyMetadata := make(map[string]map[string]string)
|
||||||
|
metadata, err = d.getDonutBucketMetadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = iodine.ToError(err)
|
// intentionally left out the error when Donut is empty
|
||||||
if os.IsNotExist(err) {
|
// but we need to revisit this area in future - since we need
|
||||||
// valid case
|
// to figure out between acceptable and unacceptable errors
|
||||||
return nil, nil
|
return dummyMetadata, nil
|
||||||
}
|
|
||||||
return nil, iodine.New(err, nil)
|
|
||||||
}
|
}
|
||||||
for name := range metadata {
|
return metadata, nil
|
||||||
results = append(results, name)
|
|
||||||
}
|
|
||||||
sort.Strings(results)
|
|
||||||
return results, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListObjects - return list of objects
|
// ListObjects - return list of objects
|
||||||
|
@ -134,11 +134,14 @@ func (d donutDriver) ListBuckets() (results []drivers.BucketMetadata, err error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, name := range buckets {
|
for name, metadata := range buckets {
|
||||||
|
created, err := time.Parse(time.RFC3339Nano, metadata["created"])
|
||||||
|
if err != nil {
|
||||||
|
return nil, iodine.New(err, nil)
|
||||||
|
}
|
||||||
result := drivers.BucketMetadata{
|
result := drivers.BucketMetadata{
|
||||||
Name: name,
|
Name: name,
|
||||||
// TODO Add real created date
|
Created: created,
|
||||||
Created: time.Now().UTC(),
|
|
||||||
}
|
}
|
||||||
results = append(results, result)
|
results = append(results, result)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user