diff --git a/pkg/api/minioapi/policy_handlers.go b/pkg/api/minioapi/policy_handlers.go index cb38577bc..30c7ad724 100644 --- a/pkg/api/minioapi/policy_handlers.go +++ b/pkg/api/minioapi/policy_handlers.go @@ -23,7 +23,6 @@ import ( "github.com/gorilla/mux" mstorage "github.com/minio-io/minio/pkg/storage" - "github.com/minio-io/minio/pkg/utils/policy" ) // PUT Bucket policy @@ -35,7 +34,7 @@ func (server *minioAPI) putBucketPolicyHandler(w http.ResponseWriter, req *http. bucket := vars["bucket"] acceptsContentType := getContentType(req) - policy, ok := policy.Parsepolicy(req.Body) + policy, ok := mstorage.Parsepolicy(req.Body) if ok == false { error := errorCodeError(InvalidPolicyDocument) errorResponse := getErrorResponse(error, bucket) diff --git a/pkg/storage/fs/fs.go b/pkg/storage/fs/fs.go index d271db21b..eb529d87a 100644 --- a/pkg/storage/fs/fs.go +++ b/pkg/storage/fs/fs.go @@ -33,7 +33,6 @@ import ( "sync" mstorage "github.com/minio-io/minio/pkg/storage" - "github.com/minio-io/minio/pkg/utils/policy" ) // Storage - fs local variables @@ -130,44 +129,44 @@ func (storage *Storage) StoreBucket(bucket string) error { } // GetBucketPolicy - GET bucket policy -func (storage *Storage) GetBucketPolicy(bucket string) (interface{}, error) { +func (storage *Storage) GetBucketPolicy(bucket string) (mstorage.BucketPolicy, error) { storage.lock.Lock() defer storage.lock.Unlock() - var p policy.BucketPolicy + var p mstorage.BucketPolicy // verify bucket path legal if mstorage.IsValidBucket(bucket) == false { - return policy.BucketPolicy{}, mstorage.BucketNameInvalid{Bucket: bucket} + return mstorage.BucketPolicy{}, mstorage.BucketNameInvalid{Bucket: bucket} } // get bucket path bucketDir := path.Join(storage.root, bucket) // check if bucket exists if _, err := os.Stat(bucketDir); err != nil { - return policy.BucketPolicy{}, mstorage.BucketNotFound{Bucket: bucket} + return mstorage.BucketPolicy{}, mstorage.BucketNotFound{Bucket: bucket} } // get policy path - bucketPolicy := path.Join(storage.root, bucket+"_policy.json") + bucketPolicy := path.Join(storage.root, bucket+"_mstoragejson") filestat, err := os.Stat(bucketPolicy) if os.IsNotExist(err) { - return policy.BucketPolicy{}, mstorage.BucketPolicyNotFound{Bucket: bucket} + return mstorage.BucketPolicy{}, mstorage.BucketPolicyNotFound{Bucket: bucket} } if filestat.IsDir() { - return policy.BucketPolicy{}, mstorage.BackendCorrupted{Path: bucketPolicy} + return mstorage.BucketPolicy{}, mstorage.BackendCorrupted{Path: bucketPolicy} } file, err := os.OpenFile(bucketPolicy, os.O_RDONLY, 0666) defer file.Close() if err != nil { - return policy.BucketPolicy{}, mstorage.EmbedError(bucket, "", err) + return mstorage.BucketPolicy{}, mstorage.EmbedError(bucket, "", err) } encoder := json.NewDecoder(file) err = encoder.Decode(&p) if err != nil { - return policy.BucketPolicy{}, mstorage.EmbedError(bucket, "", err) + return mstorage.BucketPolicy{}, mstorage.EmbedError(bucket, "", err) } return p, nil @@ -175,7 +174,7 @@ func (storage *Storage) GetBucketPolicy(bucket string) (interface{}, error) { } // StoreBucketPolicy - PUT bucket policy -func (storage *Storage) StoreBucketPolicy(bucket string, policy interface{}) error { +func (storage *Storage) StoreBucketPolicy(bucket string, p mstorage.BucketPolicy) error { storage.lock.Lock() defer storage.lock.Unlock() @@ -208,7 +207,7 @@ func (storage *Storage) StoreBucketPolicy(bucket string, policy interface{}) err return mstorage.EmbedError(bucket, "", err) } encoder := json.NewEncoder(file) - err = encoder.Encode(policy) + err = encoder.Encode(p) if err != nil { return mstorage.EmbedError(bucket, "", err) } diff --git a/pkg/storage/inmemory/inmemory.go b/pkg/storage/inmemory/inmemory.go index 524778234..2cf3f5dc2 100644 --- a/pkg/storage/inmemory/inmemory.go +++ b/pkg/storage/inmemory/inmemory.go @@ -28,7 +28,6 @@ import ( "time" mstorage "github.com/minio-io/minio/pkg/storage" - "github.com/minio-io/minio/pkg/utils/policy" ) // Storage - local variables @@ -78,13 +77,13 @@ func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object st } // StoreBucketPolicy - Not implemented -func (storage *Storage) StoreBucketPolicy(bucket string, policy interface{}) error { +func (storage *Storage) StoreBucketPolicy(bucket string, policy mstorage.BucketPolicy) error { return mstorage.APINotImplemented{API: "PutBucketPolicy"} } // GetBucketPolicy - Not implemented -func (storage *Storage) GetBucketPolicy(bucket string) (interface{}, error) { - return policy.BucketPolicy{}, mstorage.APINotImplemented{API: "GetBucketPolicy"} +func (storage *Storage) GetBucketPolicy(bucket string) (mstorage.BucketPolicy, error) { + return mstorage.BucketPolicy{}, mstorage.APINotImplemented{API: "GetBucketPolicy"} } // StoreObject - PUT object to memory buffer diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index ec04fd0cf..b5607ae06 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -28,8 +28,8 @@ type Storage interface { // Bucket Operations ListBuckets() ([]BucketMetadata, error) StoreBucket(bucket string) error - StoreBucketPolicy(bucket string, policy interface{}) error - GetBucketPolicy(bucket string) (interface{}, error) + StoreBucketPolicy(bucket string, p BucketPolicy) error + GetBucketPolicy(bucket string) (BucketPolicy, error) // Object Operations CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) diff --git a/pkg/utils/policy/date.go b/pkg/storage/storage_bucket_date.go similarity index 98% rename from pkg/utils/policy/date.go rename to pkg/storage/storage_bucket_date.go index e45bc191e..7c6d31ffc 100644 --- a/pkg/utils/policy/date.go +++ b/pkg/storage/storage_bucket_date.go @@ -1,4 +1,4 @@ -package policy +package storage import ( "fmt" diff --git a/pkg/utils/policy/policy.go b/pkg/storage/storage_bucket_policy.go similarity index 99% rename from pkg/utils/policy/policy.go rename to pkg/storage/storage_bucket_policy.go index 50de391b0..f4b80ebbc 100644 --- a/pkg/utils/policy/policy.go +++ b/pkg/storage/storage_bucket_policy.go @@ -1,4 +1,4 @@ -package policy +package storage import ( "encoding/json"