mirror of https://github.com/minio/minio.git
Browse Source
cleanup: Remove definitions and move them to its relative places accordingly
cleanup: Remove definitions and move them to its relative places accordingly
- Move fs-definitions.go and break them into fs-datatypes.go, fs-bucket-acl.go and fs-utils.go - Move api-definitions.go to api-response.go, where they should be. - Move web-definitions to its related handlers.pull/1144/head

14 changed files with 358 additions and 457 deletions
-
225api-definitions.go
-
230api-response.go
-
28generic-handlers.go
-
2pkg/fs/fs-backend-metadata.go
-
48pkg/fs/fs-bucket-acl.go
-
23pkg/fs/fs-bucket.go
-
94pkg/fs/fs-common.go
-
83pkg/fs/fs-datatypes.go
-
0pkg/fs/fs-errors.go
-
7pkg/fs/fs-multipart.go
-
2pkg/fs/fs-object.go
-
55pkg/fs/fs-utils.go
-
1pkg/probe/probe_test.go
-
17web-definitions.go
@ -1,225 +0,0 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2015 Minio, Inc. |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
package main |
|||
|
|||
import "encoding/xml" |
|||
|
|||
// Limit number of objects in a given response.
|
|||
const ( |
|||
maxObjectList = 1000 |
|||
) |
|||
|
|||
// LocationResponse - format for location response.
|
|||
type LocationResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LocationConstraint" json:"-"` |
|||
Location string `xml:",chardata"` |
|||
} |
|||
|
|||
// AccessControlPolicyResponse - format for get bucket acl response.
|
|||
type AccessControlPolicyResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ AccessControlPolicy" json:"-"` |
|||
|
|||
AccessControlList struct { |
|||
Grant []Grant |
|||
} |
|||
Owner Owner |
|||
} |
|||
|
|||
// Grant container for grantee and permission.
|
|||
type Grant struct { |
|||
Grantee struct { |
|||
ID string |
|||
DisplayName string |
|||
EmailAddress string |
|||
Type string |
|||
URI string |
|||
} |
|||
Permission string |
|||
} |
|||
|
|||
// ListObjectsResponse - format for list objects response.
|
|||
type ListObjectsResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"` |
|||
|
|||
CommonPrefixes []*CommonPrefix |
|||
Contents []*Object |
|||
|
|||
Delimiter string |
|||
|
|||
// Encoding type used to encode object keys in the response.
|
|||
EncodingType string |
|||
|
|||
// A flag that indicates whether or not ListObjects returned all of the results
|
|||
// that satisfied the search criteria.
|
|||
IsTruncated bool |
|||
Marker string |
|||
MaxKeys int |
|||
Name string |
|||
|
|||
// When response is truncated (the IsTruncated element value in the response
|
|||
// is true), you can use the key name in this field as marker in the subsequent
|
|||
// request to get next set of objects. Server lists objects in alphabetical
|
|||
// order Note: This element is returned only if you have delimiter request parameter
|
|||
// specified. If response does not include the NextMaker and it is truncated,
|
|||
// you can use the value of the last Key in the response as the marker in the
|
|||
// subsequent request to get the next set of object keys.
|
|||
NextMarker string |
|||
Prefix string |
|||
} |
|||
|
|||
// Part container for part metadata.
|
|||
type Part struct { |
|||
PartNumber int |
|||
ETag string |
|||
LastModified string |
|||
Size int64 |
|||
} |
|||
|
|||
// ListPartsResponse - format for list parts response.
|
|||
type ListPartsResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListPartsResult" json:"-"` |
|||
|
|||
Bucket string |
|||
Key string |
|||
UploadID string `xml:"UploadId"` |
|||
|
|||
Initiator Initiator |
|||
Owner Owner |
|||
|
|||
// The class of storage used to store the object.
|
|||
StorageClass string |
|||
|
|||
PartNumberMarker int |
|||
NextPartNumberMarker int |
|||
MaxParts int |
|||
IsTruncated bool |
|||
|
|||
// List of parts.
|
|||
Part []*Part |
|||
} |
|||
|
|||
// ListMultipartUploadsResponse - format for list multipart uploads response.
|
|||
type ListMultipartUploadsResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListMultipartUploadsResult" json:"-"` |
|||
|
|||
Bucket string |
|||
KeyMarker string |
|||
UploadIDMarker string `xml:"UploadIdMarker"` |
|||
NextKeyMarker string |
|||
NextUploadIDMarker string `xml:"NextUploadIdMarker"` |
|||
EncodingType string |
|||
MaxUploads int |
|||
IsTruncated bool |
|||
Upload []*Upload |
|||
Prefix string |
|||
Delimiter string |
|||
CommonPrefixes []*CommonPrefix |
|||
} |
|||
|
|||
// ListBucketsResponse - format for list buckets response
|
|||
type ListBucketsResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"` |
|||
// Container for one or more buckets.
|
|||
Buckets struct { |
|||
Bucket []*Bucket |
|||
} // Buckets are nested
|
|||
Owner Owner |
|||
} |
|||
|
|||
// Upload container for in progress multipart upload
|
|||
type Upload struct { |
|||
Key string |
|||
UploadID string `xml:"UploadId"` |
|||
Initiator Initiator |
|||
Owner Owner |
|||
StorageClass string |
|||
Initiated string |
|||
} |
|||
|
|||
// CommonPrefix container for prefix response in ListObjectsResponse
|
|||
type CommonPrefix struct { |
|||
Prefix string |
|||
} |
|||
|
|||
// Bucket container for bucket metadata
|
|||
type Bucket struct { |
|||
Name string |
|||
CreationDate string |
|||
} |
|||
|
|||
// Object container for object metadata
|
|||
type Object struct { |
|||
ETag string |
|||
Key string |
|||
LastModified string |
|||
Size int64 |
|||
|
|||
Owner Owner |
|||
|
|||
// The class of storage used to store the object.
|
|||
StorageClass string |
|||
} |
|||
|
|||
// Initiator inherit from Owner struct, fields are same
|
|||
type Initiator Owner |
|||
|
|||
// Owner - bucket owner/principal
|
|||
type Owner struct { |
|||
ID string |
|||
DisplayName string |
|||
} |
|||
|
|||
// InitiateMultipartUploadResponse container for InitiateMultiPartUpload response, provides uploadID to start MultiPart upload
|
|||
type InitiateMultipartUploadResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ InitiateMultipartUploadResult" json:"-"` |
|||
|
|||
Bucket string |
|||
Key string |
|||
UploadID string `xml:"UploadId"` |
|||
} |
|||
|
|||
// CompleteMultipartUploadResponse container for completed multipart upload response
|
|||
type CompleteMultipartUploadResponse struct { |
|||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUploadResult" json:"-"` |
|||
|
|||
Location string |
|||
Bucket string |
|||
Key string |
|||
ETag string |
|||
} |
|||
|
|||
// List of not implemented bucket queries
|
|||
var notimplementedBucketResourceNames = map[string]bool{ |
|||
"policy": true, |
|||
"cors": true, |
|||
"lifecycle": true, |
|||
"logging": true, |
|||
"notification": true, |
|||
"replication": true, |
|||
"tagging": true, |
|||
"versions": true, |
|||
"requestPayment": true, |
|||
"versioning": true, |
|||
"website": true, |
|||
} |
|||
|
|||
// List of not implemented object queries
|
|||
var notimplementedObjectResourceNames = map[string]bool{ |
|||
"torrent": true, |
|||
"acl": true, |
|||
"policy": true, |
|||
} |
@ -1,5 +1,5 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2015 Minio, Inc. |
|||
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
@ -1,94 +0,0 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2015 Minio, Inc. |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
package fs |
|||
|
|||
import ( |
|||
"bufio" |
|||
"bytes" |
|||
"os" |
|||
"sort" |
|||
"strings" |
|||
"time" |
|||
) |
|||
|
|||
// Metadata - carries metadata about object
|
|||
type Metadata struct { |
|||
MD5sum []byte |
|||
ContentType string |
|||
} |
|||
|
|||
// sanitizeWindowsPath - sanitize a path
|
|||
func sanitizeWindowsPath(path string) string { |
|||
return strings.Replace(path, "\\", "/", -1) |
|||
} |
|||
|
|||
// sanitizeWindowsPaths - sanitize some windows paths
|
|||
func sanitizeWindowsPaths(paths ...string) []string { |
|||
var results []string |
|||
for _, path := range paths { |
|||
results = append(results, sanitizeWindowsPath(path)) |
|||
} |
|||
return results |
|||
} |
|||
|
|||
// sortUnique returns n, the number of distinct elements in data in sorted order.
|
|||
func sortUnique(data sort.Interface) (n int) { |
|||
if n = data.Len(); n < 2 { |
|||
return n |
|||
} |
|||
sort.Sort(data) |
|||
a, b := 0, 1 |
|||
for b < n { |
|||
if data.Less(a, b) { |
|||
a++ |
|||
if a != b { |
|||
data.Swap(a, b) |
|||
} |
|||
} |
|||
b++ |
|||
} |
|||
return a + 1 |
|||
} |
|||
|
|||
type contentInfo struct { |
|||
os.FileInfo |
|||
Prefix string |
|||
Size int64 |
|||
Mode os.FileMode |
|||
ModTime time.Time |
|||
} |
|||
|
|||
type bucketDir struct { |
|||
files []contentInfo |
|||
root string |
|||
} |
|||
|
|||
func delimiter(object, delimiter string) string { |
|||
readBuffer := bytes.NewBufferString(object) |
|||
reader := bufio.NewReader(readBuffer) |
|||
stringReader := strings.NewReader(delimiter) |
|||
delimited, _ := stringReader.ReadByte() |
|||
delimitedStr, _ := reader.ReadString(delimited) |
|||
return delimitedStr |
|||
} |
|||
|
|||
// byObjectMetadataKey is a sortable interface for UploadMetadata slice
|
|||
type byUploadMetadataKey []*UploadMetadata |
|||
|
|||
func (b byUploadMetadataKey) Len() int { return len(b) } |
|||
func (b byUploadMetadataKey) Swap(i, j int) { b[i], b[j] = b[j], b[i] } |
|||
func (b byUploadMetadataKey) Less(i, j int) bool { return b[i].Object < b[j].Object } |
@ -0,0 +1,55 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
package fs |
|||
|
|||
import ( |
|||
"regexp" |
|||
"unicode/utf8" |
|||
) |
|||
|
|||
// validBucket regexp.
|
|||
var validBucket = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`) |
|||
|
|||
// IsValidBucketName - verify bucket name in accordance with
|
|||
// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html
|
|||
func IsValidBucketName(bucket string) bool { |
|||
if bucket == "" { |
|||
return false |
|||
} |
|||
if len(bucket) < 3 || len(bucket) > 63 { |
|||
return false |
|||
} |
|||
if bucket[0] == '.' || bucket[len(bucket)-1] == '.' { |
|||
return false |
|||
} |
|||
return validBucket.MatchString(bucket) |
|||
} |
|||
|
|||
// IsValidObjectName - verify object name in accordance with
|
|||
// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
|
|||
func IsValidObjectName(object string) bool { |
|||
if object == "" { |
|||
return true |
|||
} |
|||
if len(object) > 1024 || len(object) == 0 { |
|||
return false |
|||
} |
|||
if !utf8.ValidString(object) { |
|||
return false |
|||
} |
|||
return true |
|||
} |
@ -1,17 +0,0 @@ |
|||
/* |
|||
* Minio Cloud Storage, (C) 2016 Minio, Inc. |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
package main |
Write
Preview
Loading…
Cancel
Save
Reference in new issue