2015-06-23 14:44:32 -04:00
|
|
|
/*
|
2015-07-24 20:51:40 -04:00
|
|
|
* Minio Cloud Storage, (C) 2015 Minio, Inc.
|
2015-06-23 14:44:32 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
fs: Break fs package to top-level and introduce ObjectAPI interface.
ObjectAPI interface brings in changes needed for XL ObjectAPI layer.
The new interface for any ObjectAPI layer is as below
```
// ObjectAPI interface.
type ObjectAPI interface {
// Bucket resource API.
DeleteBucket(bucket string) *probe.Error
ListBuckets() ([]BucketInfo, *probe.Error)
MakeBucket(bucket string) *probe.Error
GetBucketInfo(bucket string) (BucketInfo, *probe.Error)
// Bucket query API.
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsResult, *probe.Error)
ListMultipartUploads(bucket string, resources BucketMultipartResourcesMetadata) (BucketMultipartResourcesMetadata, *probe.Error)
// Object resource API.
GetObject(bucket, object string, startOffset int64) (io.ReadCloser, *probe.Error)
GetObjectInfo(bucket, object string) (ObjectInfo, *probe.Error)
PutObject(bucket string, object string, size int64, data io.Reader, metadata map[string]string) (ObjectInfo, *probe.Error)
DeleteObject(bucket, object string) *probe.Error
// Object query API.
NewMultipartUpload(bucket, object string) (string, *probe.Error)
PutObjectPart(bucket, object, uploadID string, partID int, size int64, data io.Reader, md5Hex string) (string, *probe.Error)
ListObjectParts(bucket, object string, resources ObjectResourcesMetadata) (ObjectResourcesMetadata, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []CompletePart) (ObjectInfo, *probe.Error)
AbortMultipartUpload(bucket, object, uploadID string) *probe.Error
}
```
2016-03-30 19:15:28 -04:00
|
|
|
package main
|
2015-06-23 14:44:32 -04:00
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
import "fmt"
|
|
|
|
|
2016-04-19 05:42:10 -04:00
|
|
|
// StorageFull storage ran out of space
|
|
|
|
type StorageFull struct{}
|
2015-06-23 14:44:32 -04:00
|
|
|
|
2016-04-19 05:42:10 -04:00
|
|
|
func (e StorageFull) Error() string {
|
|
|
|
return "Storage reached its minimum free disk threshold."
|
2015-06-23 14:44:32 -04:00
|
|
|
}
|
|
|
|
|
2016-04-19 05:42:10 -04:00
|
|
|
// GenericError - generic object layer error.
|
|
|
|
type GenericError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
2015-10-17 22:17:33 -04:00
|
|
|
}
|
|
|
|
|
2015-06-23 14:44:32 -04:00
|
|
|
// BucketNotFound bucket does not exist
|
2016-04-19 05:42:10 -04:00
|
|
|
type BucketNotFound GenericError
|
2015-06-23 14:44:32 -04:00
|
|
|
|
|
|
|
func (e BucketNotFound) Error() string {
|
|
|
|
return "Bucket not found: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
// BucketNotEmpty bucket is not empty
|
2016-04-19 05:42:10 -04:00
|
|
|
type BucketNotEmpty GenericError
|
2015-06-23 14:44:32 -04:00
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
func (e BucketNotEmpty) Error() string {
|
|
|
|
return "Bucket not empty: " + e.Bucket
|
2015-06-23 14:44:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ObjectNotFound object does not exist
|
2016-04-19 05:42:10 -04:00
|
|
|
type ObjectNotFound GenericError
|
2015-06-23 14:44:32 -04:00
|
|
|
|
|
|
|
func (e ObjectNotFound) Error() string {
|
2015-10-16 14:26:01 -04:00
|
|
|
return "Object not found: " + e.Bucket + "#" + e.Object
|
2015-06-23 14:44:32 -04:00
|
|
|
}
|
|
|
|
|
2016-02-02 18:23:28 -05:00
|
|
|
// ObjectExistsAsPrefix object already exists with a requested prefix.
|
2016-04-19 05:42:10 -04:00
|
|
|
type ObjectExistsAsPrefix GenericError
|
2016-02-02 18:23:28 -05:00
|
|
|
|
|
|
|
func (e ObjectExistsAsPrefix) Error() string {
|
2016-04-19 05:42:10 -04:00
|
|
|
return "Object exists on : " + e.Bucket + " as prefix " + e.Object
|
2015-06-23 14:44:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// BucketExists bucket exists
|
2016-04-19 05:42:10 -04:00
|
|
|
type BucketExists GenericError
|
2015-06-23 14:44:32 -04:00
|
|
|
|
|
|
|
func (e BucketExists) Error() string {
|
|
|
|
return "Bucket exists: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2016-03-12 19:08:15 -05:00
|
|
|
// BadDigest - Content-MD5 you specified did not match what we received.
|
2015-10-16 14:26:01 -04:00
|
|
|
type BadDigest struct {
|
2016-03-12 19:08:15 -05:00
|
|
|
ExpectedMD5 string
|
|
|
|
CalculatedMD5 string
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
2015-06-23 14:44:32 -04:00
|
|
|
|
|
|
|
func (e BadDigest) Error() string {
|
2016-03-12 19:08:15 -05:00
|
|
|
return "Bad digest expected " + e.ExpectedMD5 + " is not valid with what we calculated " + e.CalculatedMD5
|
2015-06-23 14:44:32 -04:00
|
|
|
}
|
|
|
|
|
2016-04-11 04:29:18 -04:00
|
|
|
// UnsupportedDelimiter - unsupported delimiter.
|
|
|
|
type UnsupportedDelimiter struct {
|
|
|
|
Delimiter string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e UnsupportedDelimiter) Error() string {
|
|
|
|
return fmt.Sprintf("delimiter '%s' is not supported. Only '/' is supported", e.Delimiter)
|
|
|
|
}
|
|
|
|
|
2016-04-19 05:42:10 -04:00
|
|
|
// InvalidUploadIDKeyCombination - invalid upload id and key marker combination.
|
2016-04-11 04:29:18 -04:00
|
|
|
type InvalidUploadIDKeyCombination struct {
|
|
|
|
UploadIDMarker, KeyMarker string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidUploadIDKeyCombination) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid combination of uploadID marker '%s' and marker '%s'", e.UploadIDMarker, e.KeyMarker)
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidMarkerPrefixCombination - invalid marker and prefix combination.
|
|
|
|
type InvalidMarkerPrefixCombination struct {
|
|
|
|
Marker, Prefix string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidMarkerPrefixCombination) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid combination of marker '%s' and prefix '%s'", e.Marker, e.Prefix)
|
|
|
|
}
|
|
|
|
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
// BucketPolicyNotFound - no bucket policy found.
|
2016-04-19 05:42:10 -04:00
|
|
|
type BucketPolicyNotFound GenericError
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
|
|
|
|
func (e BucketPolicyNotFound) Error() string {
|
|
|
|
return "No bucket policy found for bucket: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
/// Bucket related errors
|
|
|
|
|
|
|
|
// BucketNameInvalid - bucketname provided is invalid
|
2016-04-19 05:42:10 -04:00
|
|
|
type BucketNameInvalid GenericError
|
2015-06-30 19:30:02 -04:00
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BucketNameInvalid) Error() string {
|
|
|
|
return "Bucket name invalid: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2016-04-19 05:42:10 -04:00
|
|
|
/// Object related errors
|
|
|
|
|
|
|
|
// ObjectNameInvalid - object name provided is invalid
|
|
|
|
type ObjectNameInvalid GenericError
|
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ObjectNameInvalid) Error() string {
|
|
|
|
return "Object name invalid: " + e.Bucket + "#" + e.Object
|
|
|
|
}
|
|
|
|
|
2016-04-25 13:39:28 -04:00
|
|
|
// UnExpectedDataSize - Reader contains more/less data than specified.
|
|
|
|
type UnExpectedDataSize struct {
|
|
|
|
Size int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e UnExpectedDataSize) Error() string {
|
|
|
|
return fmt.Sprintf("Contains more data than specified size of %d bytes.", e.Size)
|
|
|
|
}
|
|
|
|
|
2015-07-08 23:18:32 -04:00
|
|
|
// IncompleteBody You did not provide the number of bytes specified by the Content-Length HTTP header
|
2016-04-19 05:42:10 -04:00
|
|
|
type IncompleteBody GenericError
|
2015-07-08 23:18:32 -04:00
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e IncompleteBody) Error() string {
|
|
|
|
return e.Bucket + "#" + e.Object + "has incomplete body"
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
/// Multipart related errors
|
|
|
|
|
2016-04-11 04:29:18 -04:00
|
|
|
// MalformedUploadID malformed upload id.
|
|
|
|
type MalformedUploadID struct {
|
|
|
|
UploadID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e MalformedUploadID) Error() string {
|
|
|
|
return "Malformed upload id " + e.UploadID
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidUploadID invalid upload id.
|
2015-06-30 19:30:02 -04:00
|
|
|
type InvalidUploadID struct {
|
|
|
|
UploadID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidUploadID) Error() string {
|
|
|
|
return "Invalid upload id " + e.UploadID
|
|
|
|
}
|
2015-07-08 19:54:32 -04:00
|
|
|
|
2015-07-13 22:29:32 -04:00
|
|
|
// InvalidPart One or more of the specified parts could not be found
|
|
|
|
type InvalidPart struct{}
|
|
|
|
|
|
|
|
func (e InvalidPart) Error() string {
|
|
|
|
return "One or more of the specified parts could not be found"
|
|
|
|
}
|
|
|
|
|
2015-07-09 22:01:15 -04:00
|
|
|
// InvalidPartOrder parts are not ordered as Requested
|
|
|
|
type InvalidPartOrder struct {
|
|
|
|
UploadID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidPartOrder) Error() string {
|
|
|
|
return "Invalid part order sent for " + e.UploadID
|
|
|
|
}
|