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.
|
|
|
|
*/
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
package fs
|
2015-06-23 14:44:32 -04:00
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
import "fmt"
|
|
|
|
|
2015-06-23 14:44:32 -04:00
|
|
|
// InvalidArgument invalid argument
|
|
|
|
type InvalidArgument struct{}
|
|
|
|
|
|
|
|
func (e InvalidArgument) Error() string {
|
|
|
|
return "Invalid argument"
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnsupportedFilesystem unsupported filesystem type
|
|
|
|
type UnsupportedFilesystem struct {
|
|
|
|
Type string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e UnsupportedFilesystem) Error() string {
|
|
|
|
return "Unsupported filesystem: " + e.Type
|
|
|
|
}
|
|
|
|
|
2015-10-17 22:17:33 -04:00
|
|
|
// RootPathFull root path out of space
|
|
|
|
type RootPathFull struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e RootPathFull) Error() string {
|
|
|
|
return "Root path " + e.Path + " reached its minimum free disk threshold."
|
|
|
|
}
|
|
|
|
|
2015-06-23 14:44:32 -04:00
|
|
|
// BucketNotFound bucket does not exist
|
|
|
|
type BucketNotFound struct {
|
|
|
|
Bucket string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e BucketNotFound) Error() string {
|
|
|
|
return "Bucket not found: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-10-16 14:26:01 -04:00
|
|
|
// BucketNotEmpty bucket is not empty
|
|
|
|
type BucketNotEmpty struct {
|
|
|
|
Bucket string
|
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
|
|
|
|
type ObjectNotFound struct {
|
2015-10-16 14:26:01 -04:00
|
|
|
Bucket string
|
2015-06-23 14:44:32 -04:00
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
|
|
|
type ObjectExistsAsPrefix struct {
|
|
|
|
Bucket string
|
|
|
|
Prefix string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ObjectExistsAsPrefix) Error() string {
|
|
|
|
return "Object exists on : " + e.Bucket + " as prefix " + e.Prefix
|
|
|
|
}
|
|
|
|
|
2015-06-23 14:44:32 -04:00
|
|
|
// ObjectCorrupted object found to be corrupted
|
|
|
|
type ObjectCorrupted struct {
|
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ObjectCorrupted) Error() string {
|
|
|
|
return "Object found corrupted: " + e.Object
|
|
|
|
}
|
|
|
|
|
|
|
|
// BucketExists bucket exists
|
|
|
|
type BucketExists struct {
|
|
|
|
Bucket string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e BucketExists) Error() string {
|
|
|
|
return "Bucket exists: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
|
|
|
// CorruptedBackend backend found to be corrupted
|
|
|
|
type CorruptedBackend struct {
|
|
|
|
Backend string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e CorruptedBackend) Error() string {
|
|
|
|
return "Corrupted backend: " + e.Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotImplemented function not implemented
|
|
|
|
type NotImplemented struct {
|
|
|
|
Function string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e NotImplemented) Error() string {
|
|
|
|
return "Not implemented: " + e.Function
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidDisksArgument invalid number of disks per node
|
|
|
|
type InvalidDisksArgument struct{}
|
|
|
|
|
|
|
|
func (e InvalidDisksArgument) Error() string {
|
|
|
|
return "Invalid number of disks per node"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
// InternalError - generic internal error
|
2016-02-15 20:42:39 -05:00
|
|
|
type InternalError struct{}
|
2015-06-30 19:30:02 -04:00
|
|
|
|
|
|
|
// BackendError - generic disk backend error
|
|
|
|
type BackendError struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
|
|
|
// BackendCorrupted - path has corrupted data
|
|
|
|
type BackendCorrupted BackendError
|
|
|
|
|
|
|
|
// APINotImplemented - generic API not implemented error
|
|
|
|
type APINotImplemented struct {
|
|
|
|
API string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GenericBucketError - generic bucket error
|
|
|
|
type GenericBucketError struct {
|
|
|
|
Bucket string
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
type BucketPolicyNotFound GenericBucketError
|
|
|
|
|
|
|
|
func (e BucketPolicyNotFound) Error() string {
|
|
|
|
return "No bucket policy found for bucket: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:30:02 -04:00
|
|
|
// GenericObjectError - generic object error
|
|
|
|
type GenericObjectError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ImplementationError - generic implementation error
|
|
|
|
type ImplementationError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Bucket related errors
|
|
|
|
|
|
|
|
// BucketNameInvalid - bucketname provided is invalid
|
|
|
|
type BucketNameInvalid GenericBucketError
|
|
|
|
|
|
|
|
/// Object related errors
|
|
|
|
|
|
|
|
// ObjectNameInvalid - object name provided is invalid
|
|
|
|
type ObjectNameInvalid GenericObjectError
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ImplementationError) Error() string {
|
|
|
|
error := ""
|
|
|
|
if e.Bucket != "" {
|
|
|
|
error = error + "Bucket: " + e.Bucket + " "
|
|
|
|
}
|
|
|
|
if e.Object != "" {
|
|
|
|
error = error + "Object: " + e.Object + " "
|
|
|
|
}
|
|
|
|
error = error + "Error: " + e.Err.Error()
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
|
|
|
|
// EmbedError - wrapper function for error object
|
|
|
|
func EmbedError(bucket, object string, err error) ImplementationError {
|
|
|
|
return ImplementationError{
|
|
|
|
Bucket: bucket,
|
|
|
|
Object: object,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e InternalError) Error() string {
|
|
|
|
return "Internal error occured"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e APINotImplemented) Error() string {
|
|
|
|
return "Api not implemented: " + e.API
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BucketNameInvalid) Error() string {
|
|
|
|
return "Bucket name invalid: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ObjectNameInvalid) Error() string {
|
|
|
|
return "Object name invalid: " + e.Bucket + "#" + e.Object
|
|
|
|
}
|
|
|
|
|
2015-07-08 23:18:32 -04:00
|
|
|
// IncompleteBody You did not provide the number of bytes specified by the Content-Length HTTP header
|
|
|
|
type IncompleteBody GenericObjectError
|
|
|
|
|
|
|
|
// 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
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BackendCorrupted) Error() string {
|
|
|
|
return "Backend corrupted: " + e.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
// OperationNotPermitted - operation not permitted
|
|
|
|
type OperationNotPermitted struct {
|
|
|
|
Op string
|
|
|
|
Reason string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e OperationNotPermitted) Error() string {
|
|
|
|
return "Operation " + e.Op + " not permitted for reason: " + e.Reason
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidRange - invalid range
|
|
|
|
type InvalidRange struct {
|
|
|
|
Start int64
|
|
|
|
Length int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidRange) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid range start:%d length:%d", e.Start, e.Length)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Multipart related errors
|
|
|
|
|
|
|
|
// InvalidUploadID invalid upload id
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// MalformedXML invalid xml format
|
|
|
|
type MalformedXML struct{}
|
|
|
|
|
|
|
|
func (e MalformedXML) Error() string {
|
|
|
|
return "Malformed XML"
|
|
|
|
}
|