From 9ec8925f1c7e078f036f3572426be0710e3a41a9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 1 May 2015 20:29:01 -0700 Subject: [PATCH] Rename IsValidObject() to IsValidObjectName() --- pkg/storage/drivers/donut/donut.go | 10 +++++----- pkg/storage/drivers/driver.go | 4 ++-- pkg/storage/drivers/memory/memory.go | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/storage/drivers/donut/donut.go b/pkg/storage/drivers/donut/donut.go index ba48622b7..2f10dae30 100644 --- a/pkg/storage/drivers/donut/donut.go +++ b/pkg/storage/drivers/donut/donut.go @@ -212,7 +212,7 @@ func (d donutDriver) GetObject(target io.Writer, bucketName, objectName string) if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil) } - if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" { + if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" { return 0, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil) } reader, size, err := d.donut.GetObject(bucketName, objectName) @@ -238,7 +238,7 @@ func (d donutDriver) GetPartialObject(w io.Writer, bucketName, objectName string if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, errParams) } - if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" { + if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" { return 0, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, errParams) } if start < 0 { @@ -282,7 +282,7 @@ func (d donutDriver) GetObjectMetadata(bucketName, objectName, prefixName string if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil) } - if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" { + if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" { return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil) } metadata, err := d.donut.GetObjectMetadata(bucketName, objectName) @@ -326,7 +326,7 @@ func (d donutDriver) ListObjects(bucketName string, resources drivers.BucketReso if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { return nil, drivers.BucketResourcesMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil) } - if !drivers.IsValidObject(resources.Prefix) { + if !drivers.IsValidObjectName(resources.Prefix) { return nil, drivers.BucketResourcesMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: resources.Prefix}, nil) } actualObjects, commonPrefixes, isTruncated, err := d.donut.ListObjects(bucketName, @@ -375,7 +375,7 @@ func (d donutDriver) CreateObject(bucketName, objectName, contentType, expectedM if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") { return "", iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil) } - if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" { + if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" { return "", iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil) } if strings.TrimSpace(contentType) == "" { diff --git a/pkg/storage/drivers/driver.go b/pkg/storage/drivers/driver.go index f6d270f9d..8f50acba7 100644 --- a/pkg/storage/drivers/driver.go +++ b/pkg/storage/drivers/driver.go @@ -184,9 +184,9 @@ func IsValidBucket(bucket string) bool { return match } -// IsValidObject - verify object name in accordance with +// IsValidObjectName - verify object name in accordance with // - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html -func IsValidObject(object string) bool { +func IsValidObjectName(object string) bool { if strings.TrimSpace(object) == "" { return true } diff --git a/pkg/storage/drivers/memory/memory.go b/pkg/storage/drivers/memory/memory.go index 8a198e7da..6131c4184 100644 --- a/pkg/storage/drivers/memory/memory.go +++ b/pkg/storage/drivers/memory/memory.go @@ -104,7 +104,7 @@ func (memory *memoryDriver) GetObject(w io.Writer, bucket string, object string) memory.lock.RUnlock() return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) } - if !drivers.IsValidObject(object) { + if !drivers.IsValidObjectName(object) { memory.lock.RUnlock() return 0, iodine.New(drivers.ObjectNameInvalid{Object: object}, nil) } @@ -137,7 +137,7 @@ func (memory *memoryDriver) GetPartialObject(w io.Writer, bucket, object string, if !drivers.IsValidBucket(bucket) { return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) } - if !drivers.IsValidObject(object) { + if !drivers.IsValidObjectName(object) { return 0, iodine.New(drivers.ObjectNameInvalid{Object: object}, nil) } if _, err := memory.GetObject(&sourceBuffer, bucket, object); err != nil { @@ -217,7 +217,7 @@ func (memory *memoryDriver) createObject(bucket, key, contentType, expectedMD5Su memory.lock.RUnlock() return "", iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) } - if !drivers.IsValidObject(key) { + if !drivers.IsValidObjectName(key) { memory.lock.RUnlock() return "", iodine.New(drivers.ObjectNameInvalid{Object: key}, nil) } @@ -408,7 +408,7 @@ func (memory *memoryDriver) ListObjects(bucket string, resources drivers.BucketR if !drivers.IsValidBucket(bucket) { return nil, drivers.BucketResourcesMetadata{IsTruncated: false}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) } - if !drivers.IsValidObject(resources.Prefix) { + if !drivers.IsValidObjectName(resources.Prefix) { return nil, drivers.BucketResourcesMetadata{IsTruncated: false}, iodine.New(drivers.ObjectNameInvalid{Object: resources.Prefix}, nil) } if _, ok := memory.storedBuckets[bucket]; ok == false { @@ -467,7 +467,7 @@ func (memory *memoryDriver) GetObjectMetadata(bucket, key, prefix string) (drive if !drivers.IsValidBucket(bucket) { return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil) } - if !drivers.IsValidObject(key) || !drivers.IsValidObject(prefix) { + if !drivers.IsValidObjectName(key) || !drivers.IsValidObjectName(prefix) { return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: key}, nil) } if _, ok := memory.storedBuckets[bucket]; ok == false {