diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go index bd88b1c3..d39cb910 100644 --- a/vendor/github.com/minio/minio-go/api.go +++ b/vendor/github.com/minio/minio-go/api.go @@ -120,6 +120,16 @@ func getRegion(host string) (region string) { return "milkyway" } +// getEndpoint returns a endpoint based on its region. +func getEndpoint(region string) (endpoint string) { + for h, r := range regions { + if r == region { + return h + } + } + return "s3.amazonaws.com" +} + // SignatureType is type of Authorization requested for a given HTTP request. type SignatureType int @@ -169,10 +179,10 @@ type Config struct { // certs which are not part of standard certificate authority follow this // example:- // - // tr := &http.Transport{ - // TLSClientConfig: &tls.Config{RootCAs: pool}, - // DisableCompression: true, - // } + // tr := &http.Transport{ + // TLSClientConfig: &tls.Config{RootCAs: pool}, + // DisableCompression: true, + // } // Transport http.RoundTripper @@ -251,7 +261,7 @@ func (c *Config) setBucketRegion() { return } -// Construct final endpoint based on region, bucket and scheme +// setEndpoint - construct final endpoint based on region, bucket and scheme func (c *Config) setEndpoint(region, bucket, scheme string) { var host string for k, v := range regions { @@ -259,7 +269,7 @@ func (c *Config) setEndpoint(region, bucket, scheme string) { host = k } } - // Construct the new URL endpoint based on the region. + // construct the new URL endpoint based on the region. newURL := new(url.URL) newURL.Host = bucket + "." + host newURL.Scheme = scheme @@ -327,9 +337,8 @@ func (a API) PresignedPostPolicy(p *PostPolicy) (map[string]string, error) { /// Object operations. -/// Expires maximum is 7days - ie. 604800 and minimum is 1. - // PresignedPutObject get a presigned URL to upload an object. +// Expires maximum is 7days - ie. 604800 and minimum is 1. func (a API) PresignedPutObject(bucket, object string, expires time.Duration) (string, error) { expireSeconds := int64(expires / time.Second) if expireSeconds < 1 || expireSeconds > 604800 { @@ -640,11 +649,11 @@ func (a API) continueObjectUpload(bucket, object, uploadID string, size int64, d // // You must have WRITE permissions on a bucket to create an object. // -// - For size lesser than 5MB PutObject automatically does single Put operation. -// - For size equal to 0Bytes PutObject automatically does single Put operation. -// - For size larger than 5MB PutObject automatically does resumable multipart operation. -// - For size input as -1 PutObject treats it as a stream and does multipart operation until -// input stream reaches EOF. +// - For size lesser than 5MB PutObject automatically does single Put operation. +// - For size equal to 0Bytes PutObject automatically does single Put operation. +// - For size larger than 5MB PutObject automatically does resumable multipart operation. +// - For size input as -1 PutObject treats it as a stream and does multipart operation until +// input stream reaches EOF. // // NOTE: if you are using Google Cloud Storage. Then there is no resumable multipart // upload support yet. Currently PutObject will behave like a single PUT operation and would @@ -1134,8 +1143,7 @@ func (a API) listBucketsInRoutine(ch chan<- BucketStatCh) { // ListBuckets list of all buckets owned by the authenticated sender of the request. // -// This call requires explicit authentication, no anonymous -// requests are allowed for listing buckets +// This call requires explicit authentication, no anonymous requests are allowed for listing buckets. // // api := client.New(....) // for message := range api.ListBuckets() { @@ -1197,8 +1205,8 @@ func (a API) removeIncompleteUploadInRoutine(bucket, object string, errorCh chan } } -// RemoveIncompleteUpload - abort a specific in progress active multipart upload -// requires explicit authentication, no anonymous requests are allowed for multipart API +// RemoveIncompleteUpload - abort a specific in progress active multipart upload. +// Requires explicit authentication, no anonymous requests are allowed for multipart API. func (a API) RemoveIncompleteUpload(bucket, object string) <-chan error { errorCh := make(chan error) go a.removeIncompleteUploadInRoutine(bucket, object, errorCh) diff --git a/vendor/github.com/minio/minio-go/errors.go b/vendor/github.com/minio/minio-go/errors.go index fadb5dae..9ccaefa4 100644 --- a/vendor/github.com/minio/minio-go/errors.go +++ b/vendor/github.com/minio/minio-go/errors.go @@ -44,6 +44,9 @@ type ErrorResponse struct { Resource string RequestID string `xml:"RequestId"` HostID string `xml:"HostId"` + + // This is a new undocumented field + AmzBucketRegion string } // ToErrorResponse returns parsed ErrorResponse struct, if input is nil or not ErrorResponse return value is nil diff --git a/vendor/github.com/minio/minio-go/post-policy.go b/vendor/github.com/minio/minio-go/post-policy.go index 080e93f3..b2b34d7a 100644 --- a/vendor/github.com/minio/minio-go/post-policy.go +++ b/vendor/github.com/minio/minio-go/post-policy.go @@ -14,11 +14,12 @@ const expirationDateFormat = "2006-01-02T15:04:05.999Z" // policyCondition explanation: http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html // // Example: -// policyCondition { -// matchType: "$eq", -// key: "$Content-Type", -// value: "image/png", -// } +// +// policyCondition { +// matchType: "$eq", +// key: "$Content-Type", +// value: "image/png", +// } // type policyCondition struct { matchType string @@ -51,7 +52,7 @@ func NewPostPolicy() *PostPolicy { // SetExpires expiration time func (p *PostPolicy) SetExpires(t time.Time) error { if t.IsZero() { - return errors.New("time input invalid") + return errors.New("No expiry time set.") } p.expiration = t return nil @@ -60,7 +61,7 @@ func (p *PostPolicy) SetExpires(t time.Time) error { // SetKey Object name func (p *PostPolicy) SetKey(key string) error { if strings.TrimSpace(key) == "" || key == "" { - return errors.New("key invalid") + return errors.New("Object name is not specified.") } policyCond := policyCondition{ matchType: "eq", @@ -77,7 +78,7 @@ func (p *PostPolicy) SetKey(key string) error { // SetKeyStartsWith Object name that can start with func (p *PostPolicy) SetKeyStartsWith(keyStartsWith string) error { if strings.TrimSpace(keyStartsWith) == "" || keyStartsWith == "" { - return errors.New("key-starts-with invalid") + return errors.New("Object prefix is not specified.") } policyCond := policyCondition{ matchType: "starts-with", @@ -94,7 +95,7 @@ func (p *PostPolicy) SetKeyStartsWith(keyStartsWith string) error { // SetBucket bucket name func (p *PostPolicy) SetBucket(bucket string) error { if strings.TrimSpace(bucket) == "" || bucket == "" { - return errors.New("bucket invalid") + return errors.New("Bucket name is not specified.") } policyCond := policyCondition{ matchType: "eq", @@ -111,7 +112,7 @@ func (p *PostPolicy) SetBucket(bucket string) error { // SetContentType content-type func (p *PostPolicy) SetContentType(contentType string) error { if strings.TrimSpace(contentType) == "" || contentType == "" { - return errors.New("contentType invalid") + return errors.New("No content type specified.") } policyCond := policyCondition{ matchType: "eq", @@ -125,16 +126,16 @@ func (p *PostPolicy) SetContentType(contentType string) error { return nil } -// SetContentLength - set new min and max content legnth condition +// SetContentLength - set new min and max content length condition func (p *PostPolicy) SetContentLength(min, max int) error { if min > max { - return errors.New("minimum cannot be bigger than maximum") + return errors.New("Content length minimum-limit is larger than maximum-limit.") } if min < 0 { - return errors.New("minimum cannot be negative") + return errors.New("Content length minimum-limit is negative.") } if max < 0 { - return errors.New("maximum cannot be negative") + return errors.New("Content length maximum-limit is negative") } p.contentLengthRange.min = min p.contentLengthRange.max = max @@ -144,7 +145,7 @@ func (p *PostPolicy) SetContentLength(min, max int) error { // addNewPolicy - internal helper to validate adding new policies func (p *PostPolicy) addNewPolicy(policyCond policyCondition) error { if policyCond.matchType == "" || policyCond.condition == "" || policyCond.value == "" { - return errors.New("policy invalid") + return errors.New("Policy fields empty.") } p.conditions = append(p.conditions, policyCond) return nil diff --git a/vendor/github.com/minio/minio-go/s3-api.go b/vendor/github.com/minio/minio-go/s3-api.go index 3dd05eb6..d3fe3077 100644 --- a/vendor/github.com/minio/minio-go/s3-api.go +++ b/vendor/github.com/minio/minio-go/s3-api.go @@ -224,11 +224,12 @@ func (a s3API) getBucketACL(bucket string) (accessControlPolicy, error) { } if policy.AccessControlList.Grant == nil { errorResponse := ErrorResponse{ - Code: "InternalError", - Message: "Access control Grant list is empty, please report this at https://github.com/minio/minio-go/issues.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "InternalError", + Message: "Access control Grant list is empty, please report this at https://github.com/minio/minio-go/issues.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } return accessControlPolicy{}, errorResponse } @@ -373,29 +374,41 @@ func (a s3API) headBucket(bucket string) error { // Head has no response body, handle it. var errorResponse ErrorResponse switch resp.StatusCode { + case http.StatusMovedPermanently: + errorResponse = ErrorResponse{ + Code: "PermanentRedirect", + Message: "The bucket you are attempting to access must be addressed using the specified endpoint https://" + getEndpoint(resp.Header.Get("x-amz-bucket-region")) + ". Send all future requests to this endpoint.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), + } case http.StatusNotFound: errorResponse = ErrorResponse{ - Code: "NoSuchBucket", - Message: "The specified bucket does not exist.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "NoSuchBucket", + Message: "The specified bucket does not exist.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } case http.StatusForbidden: errorResponse = ErrorResponse{ - Code: "AccessDenied", - Message: "Access Denied.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "AccessDenied", + Message: "Access Denied.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } default: errorResponse = ErrorResponse{ - Code: resp.Status, - Message: resp.Status, - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: resp.Status, + Message: resp.Status, + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } return errorResponse @@ -438,35 +451,39 @@ func (a s3API) deleteBucket(bucket string) error { switch resp.StatusCode { case http.StatusNotFound: errorResponse = ErrorResponse{ - Code: "NoSuchBucket", - Message: "The specified bucket does not exist.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "NoSuchBucket", + Message: "The specified bucket does not exist.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } case http.StatusForbidden: errorResponse = ErrorResponse{ - Code: "AccessDenied", - Message: "Access Denied.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "AccessDenied", + Message: "Access Denied.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } case http.StatusConflict: errorResponse = ErrorResponse{ - Code: "Conflict", - Message: "Bucket not empty.", - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "Conflict", + Message: "Bucket not empty.", + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } default: errorResponse = ErrorResponse{ - Code: resp.Status, - Message: resp.Status, - Resource: separator + bucket, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: resp.Status, + Message: resp.Status, + Resource: separator + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } return errorResponse @@ -718,10 +735,11 @@ func (a s3API) getObject(bucket, object string, offset, length int64) (io.ReadCl date, err := time.Parse(http.TimeFormat, resp.Header.Get("Last-Modified")) if err != nil { return nil, ObjectStat{}, ErrorResponse{ - Code: "InternalError", - Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go/issues.", - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "InternalError", + Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go/issues.", + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } contentType := strings.TrimSpace(resp.Header.Get("Content-Type")) @@ -805,27 +823,30 @@ func (a s3API) headObject(bucket, object string) (ObjectStat, error) { switch resp.StatusCode { case http.StatusNotFound: errorResponse = ErrorResponse{ - Code: "NoSuchKey", - Message: "The specified key does not exist.", - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "NoSuchKey", + Message: "The specified key does not exist.", + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } case http.StatusForbidden: errorResponse = ErrorResponse{ - Code: "AccessDenied", - Message: "Access Denied.", - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "AccessDenied", + Message: "Access Denied.", + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } default: errorResponse = ErrorResponse{ - Code: resp.Status, - Message: resp.Status, - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: resp.Status, + Message: resp.Status, + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } @@ -836,19 +857,21 @@ func (a s3API) headObject(bucket, object string) (ObjectStat, error) { size, err := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64) if err != nil { return ObjectStat{}, ErrorResponse{ - Code: "InternalError", - Message: "Content-Length not recognized, please report this issue at https://github.com/minio/minio-go/issues.", - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "InternalError", + Message: "Content-Length not recognized, please report this issue at https://github.com/minio/minio-go/issues.", + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } date, err := time.Parse(http.TimeFormat, resp.Header.Get("Last-Modified")) if err != nil { return ObjectStat{}, ErrorResponse{ - Code: "InternalError", - Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go/issues.", - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "InternalError", + Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go/issues.", + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } contentType := strings.TrimSpace(resp.Header.Get("Content-Type")) @@ -892,10 +915,11 @@ func (a s3API) listBuckets() (listAllMyBucketsResult, error) { // for un-authenticated requests, amazon sends a redirect handle it. if resp.StatusCode == http.StatusTemporaryRedirect { return listAllMyBucketsResult{}, ErrorResponse{ - Code: "AccessDenied", - Message: "Anonymous access is forbidden for this operation.", - RequestID: resp.Header.Get("x-amz-request-id"), - HostID: resp.Header.Get("x-amz-id-2"), + Code: "AccessDenied", + Message: "Anonymous access is forbidden for this operation.", + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } if resp.StatusCode != http.StatusOK { diff --git a/vendor/github.com/minio/minio-go/s3-multipart-api.go b/vendor/github.com/minio/minio-go/s3-multipart-api.go index 0cf038b5..63e7570f 100644 --- a/vendor/github.com/minio/minio-go/s3-multipart-api.go +++ b/vendor/github.com/minio/minio-go/s3-multipart-api.go @@ -214,24 +214,30 @@ func (a s3API) abortMultipartUpload(bucket, object, uploadID string) error { switch resp.StatusCode { case http.StatusNotFound: errorResponse = ErrorResponse{ - Code: "NoSuchUpload", - Message: "The specified multipart upload does not exist.", - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), + Code: "NoSuchUpload", + Message: "The specified multipart upload does not exist.", + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } case http.StatusForbidden: errorResponse = ErrorResponse{ - Code: "AccessDenied", - Message: "Access Denied.", - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), + Code: "AccessDenied", + Message: "Access Denied.", + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } default: errorResponse = ErrorResponse{ - Code: resp.Status, - Message: "Unknown error, please report this at https://github.com/minio/minio-go-legacy/issues.", - Resource: separator + bucket + separator + object, - RequestID: resp.Header.Get("x-amz-request-id"), + Code: resp.Status, + Message: "Unknown error, please report this at https://github.com/minio/minio-go-legacy/issues.", + Resource: separator + bucket + separator + object, + RequestID: resp.Header.Get("x-amz-request-id"), + HostID: resp.Header.Get("x-amz-id-2"), + AmzBucketRegion: resp.Header.Get("x-amz-bucket-region"), } } return errorResponse diff --git a/vendor/vendor.json b/vendor/vendor.json index 4f602e3e..7f583e2a 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -29,8 +29,8 @@ }, { "path": "github.com/minio/minio-go", - "revision": "f3e8175c352db0fe318c1e8db19f167fa83c60e3", - "revisionTime": "2015-11-14T23:15:05-08:00" + "revision": "e118c27ff5ddde1175ee1bdfd6486871442fbbb0", + "revisionTime": "2015-11-16T11:08:12-08:00" }, { "path": "github.com/minio/minio-xl/pkg/probe",