Merge pull request #285 from fkautz/pr_out_rename_storebucket_to_createbucket

master
Frederick F. Kautz IV 10 years ago
commit 1cfa2062ea
  1. 18
      pkg/api/minioapi/api_test.go
  2. 2
      pkg/api/minioapi/bucket_handlers.go
  3. 4
      pkg/storage/donut/object/objectv1/objectv1.go
  4. 4
      pkg/storage/fs/fs_bucket.go
  5. 4
      pkg/storage/inmemory/inmemory.go
  6. 4
      pkg/storage/singledisk/singledisk.go
  7. 2
      pkg/storage/storage.go
  8. 28
      pkg/storage/storage_api_suite.go

@ -60,7 +60,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
defer testServer.Close()
buffer := bytes.NewBufferString("")
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer)
response, err := http.Get(testServer.URL + "/bucket/object")
@ -85,7 +85,7 @@ func (s *MySuite) TestObject(c *C) {
defer testServer.Close()
buffer := bytes.NewBufferString("hello world")
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer)
response, err := http.Get(testServer.URL + "/bucket/object")
@ -111,7 +111,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
buffer2 := bytes.NewBufferString("hello two")
buffer3 := bytes.NewBufferString("hello three")
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object1", "", buffer1)
storage.StoreObject("bucket", "object2", "", buffer2)
storage.StoreObject("bucket", "object3", "", buffer3)
@ -203,7 +203,7 @@ func (s *MySuite) TestHeader(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusNotFound)
buffer := bytes.NewBufferString("hello world")
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
storage.StoreObject("bucket", "object", "", buffer)
response, err = http.Get(testServer.URL + "/bucket/object")
@ -312,7 +312,7 @@ func (s *MySuite) TestListBuckets(c *C) {
c.Assert(err, IsNil)
c.Assert(len(listResponse.Buckets.Bucket), Equals, 0)
storage.StoreBucket("foo")
storage.CreateBucket("foo")
response, err = http.Get(testServer.URL + "/")
defer response.Body.Close()
@ -324,7 +324,7 @@ func (s *MySuite) TestListBuckets(c *C) {
c.Assert(len(listResponse.Buckets.Bucket), Equals, 1)
c.Assert(listResponse.Buckets.Bucket[0].Name, Equals, "foo")
storage.StoreBucket("bar")
storage.CreateBucket("bar")
response, err = http.Get(testServer.URL + "/")
defer response.Body.Close()
@ -382,7 +382,7 @@ func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
testServer := httptest.NewServer(httpHandler)
defer testServer.Close()
err := storage.StoreBucket("foo")
err := storage.CreateBucket("foo")
c.Assert(err, IsNil)
request, err := http.NewRequest("GET", testServer.URL+"/", bytes.NewBufferString(""))
@ -407,7 +407,7 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
testServer := httptest.NewServer(httpHandler)
defer testServer.Close()
err := storage.StoreBucket("foo")
err := storage.CreateBucket("foo")
c.Assert(err, IsNil)
request, err := http.NewRequest("GET", testServer.URL+"/foo", bytes.NewBufferString(""))
@ -432,7 +432,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
testServer := httptest.NewServer(httpHandler)
defer testServer.Close()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, IsNil)
client := http.Client{}

@ -123,7 +123,7 @@ func (server *minioAPI) listBucketsHandler(w http.ResponseWriter, req *http.Requ
func (server *minioAPI) putBucketHandler(w http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
bucket := vars["bucket"]
err := server.storage.StoreBucket(bucket)
err := server.storage.CreateBucket(bucket)
resources := getBucketResources(req.URL.Query())
if resources.Policy == true {

@ -39,7 +39,7 @@ const (
MultipartObject
)
// Object Metadata
// ObjectMetadata contains information necessary to reconstruct the object and basic object metadata.
type ObjectMetadata struct {
Bucket string
Key string
@ -53,6 +53,7 @@ type ObjectMetadata struct {
ObjectType ObjectType
}
// Write an encoded part to a writer
func Write(target io.Writer, metadata ObjectMetadata, reader io.Reader) error {
buffer := new(bytes.Buffer)
binary.Write(buffer, binary.LittleEndian, uint32(Version))
@ -65,6 +66,7 @@ func Write(target io.Writer, metadata ObjectMetadata, reader io.Reader) error {
return err
}
// ReadMetadata reads the first elements from the stream and returns the object metadata
func ReadMetadata(reader io.Reader) (metadata ObjectMetadata, err error) {
versionBytes := make([]byte, 4)
if err := binary.Read(reader, binary.LittleEndian, versionBytes); err != nil {

@ -55,8 +55,8 @@ func (storage *Storage) ListBuckets() ([]mstorage.BucketMetadata, error) {
return metadataList, nil
}
// StoreBucket - PUT Bucket
func (storage *Storage) StoreBucket(bucket string) error {
// CreateBucket - PUT Bucket
func (storage *Storage) CreateBucket(bucket string) error {
storage.lock.Lock()
defer storage.lock.Unlock()

@ -125,8 +125,8 @@ func (storage *Storage) StoreObject(bucket, key, contentType string, data io.Rea
return nil
}
// StoreBucket - create bucket in memory
func (storage *Storage) StoreBucket(bucketName string) error {
// CreateBucket - create bucket in memory
func (storage *Storage) CreateBucket(bucketName string) error {
storage.lock.Lock()
defer storage.lock.Unlock()
if !mstorage.IsValidBucket(bucketName) {

@ -48,8 +48,8 @@ func (diskStorage StorageDriver) ListBuckets() ([]storage.BucketMetadata, error)
return nil, errors.New("Not Implemented")
}
// StoreBucket creates a new bucket
func (diskStorage StorageDriver) StoreBucket(bucket string) error {
// CreateBucket creates a new bucket
func (diskStorage StorageDriver) CreateBucket(bucket string) error {
return errors.New("Not Implemented")
}

@ -27,7 +27,7 @@ import (
type Storage interface {
// Bucket Operations
ListBuckets() ([]BucketMetadata, error)
StoreBucket(bucket string) error
CreateBucket(bucket string) error
StoreBucketPolicy(bucket string, p BucketPolicy) error
GetBucketPolicy(bucket string) (BucketPolicy, error)

@ -48,7 +48,7 @@ func testCreateBucket(c *check.C, create func() Storage) {
func testMultipleObjectCreation(c *check.C, create func() Storage) {
objects := make(map[string][]byte)
storage := create()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil)
for i := 0; i < 10; i++ {
randomPerm := rand.Perm(10)
@ -81,7 +81,7 @@ func testMultipleObjectCreation(c *check.C, create func() Storage) {
func testPaging(c *check.C, create func() Storage) {
storage := create()
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
resources := BucketResourcesMetadata{}
objects, resources, err := storage.ListObjects("bucket", resources)
c.Assert(len(objects), check.Equals, 0)
@ -183,7 +183,7 @@ func testPaging(c *check.C, create func() Storage) {
func testObjectOverwriteFails(c *check.C, create func() Storage) {
storage := create()
storage.StoreBucket("bucket")
storage.CreateBucket("bucket")
err := storage.StoreObject("bucket", "object", "", bytes.NewBufferString("one"))
c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "object", "", bytes.NewBufferString("three"))
@ -203,15 +203,15 @@ func testNonExistantBucketOperations(c *check.C, create func() Storage) {
func testBucketRecreateFails(c *check.C, create func() Storage) {
storage := create()
err := storage.StoreBucket("string")
err := storage.CreateBucket("string")
c.Assert(err, check.IsNil)
err = storage.StoreBucket("string")
err = storage.CreateBucket("string")
c.Assert(err, check.Not(check.IsNil))
}
func testPutObjectInSubdir(c *check.C, create func() Storage) {
storage := create()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world"))
c.Assert(err, check.IsNil)
@ -231,7 +231,7 @@ func testListBuckets(c *check.C, create func() Storage) {
c.Assert(err, check.IsNil)
// add one and test exists
err = storage.StoreBucket("bucket1")
err = storage.CreateBucket("bucket1")
c.Assert(err, check.IsNil)
buckets, err = storage.ListBuckets()
@ -239,7 +239,7 @@ func testListBuckets(c *check.C, create func() Storage) {
c.Assert(err, check.IsNil)
// add two and test exists
err = storage.StoreBucket("bucket2")
err = storage.CreateBucket("bucket2")
c.Assert(err, check.IsNil)
buckets, err = storage.ListBuckets()
@ -247,7 +247,7 @@ func testListBuckets(c *check.C, create func() Storage) {
c.Assert(err, check.IsNil)
// add three and test exists + prefix
err = storage.StoreBucket("bucket22")
err = storage.CreateBucket("bucket22")
buckets, err = storage.ListBuckets()
c.Assert(len(buckets), check.Equals, 3)
@ -260,8 +260,8 @@ func testListBucketsOrder(c *check.C, create func() Storage) {
for i := 0; i < 10; i++ {
storage := create()
// add one and test exists
storage.StoreBucket("bucket1")
storage.StoreBucket("bucket2")
storage.CreateBucket("bucket1")
storage.CreateBucket("bucket2")
buckets, err := storage.ListBuckets()
c.Assert(len(buckets), check.Equals, 2)
@ -282,7 +282,7 @@ func testListObjectsTestsForNonExistantBucket(c *check.C, create func() Storage)
func testNonExistantObjectInBucket(c *check.C, create func() Storage) {
storage := create()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil)
var byteBuffer bytes.Buffer
@ -304,7 +304,7 @@ func testNonExistantObjectInBucket(c *check.C, create func() Storage) {
func testGetDirectoryReturnsObjectNotFound(c *check.C, create func() Storage) {
storage := create()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil)
err = storage.StoreObject("bucket", "dir1/dir2/object", "", bytes.NewBufferString("hello world"))
@ -347,7 +347,7 @@ func testGetDirectoryReturnsObjectNotFound(c *check.C, create func() Storage) {
func testDefaultContentType(c *check.C, create func() Storage) {
storage := create()
err := storage.StoreBucket("bucket")
err := storage.CreateBucket("bucket")
c.Assert(err, check.IsNil)
// test empty

Loading…
Cancel
Save