From dade41da6f6362dd635c41da8e73da9239e388b2 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 2 Jan 2019 15:35:32 -0800 Subject: [PATCH] Add new vendored minio-go Fixes https://github.com/minio/mc/issues/2610 --- vendor/github.com/minio/minio-go/README.md | 3 +- vendor/github.com/minio/minio-go/api-stat.go | 4 +++ vendor/github.com/minio/minio-go/api.go | 15 +++++++-- vendor/github.com/minio/minio-go/appveyor.yml | 2 +- vendor/github.com/minio/minio-go/core.go | 6 ++-- .../minio/minio-go/pkg/s3utils/utils.go | 31 +++++++++++++++++- .../github.com/minio/minio-go/post-policy.go | 22 +++++++++++++ vendor/github.com/minio/minio-go/retry.go | 2 +- vendor/github.com/minio/minio-go/s3-error.go | 2 +- vendor/vendor.json | 32 +++++++++---------- 10 files changed, 93 insertions(+), 26 deletions(-) diff --git a/vendor/github.com/minio/minio-go/README.md b/vendor/github.com/minio/minio-go/README.md index 9ac8ca4245..ad9d5e60be 100644 --- a/vendor/github.com/minio/minio-go/README.md +++ b/vendor/github.com/minio/minio-go/README.md @@ -85,8 +85,9 @@ func main() { } else { log.Fatalln(err) } + } else { + log.Printf("Successfully created %s\n", bucketName) } - log.Printf("Successfully created %s\n", bucketName) // Upload the zip file objectName := "golden-oldies.zip" diff --git a/vendor/github.com/minio/minio-go/api-stat.go b/vendor/github.com/minio/minio-go/api-stat.go index 3b054c34a7..91e9d3964a 100644 --- a/vendor/github.com/minio/minio-go/api-stat.go +++ b/vendor/github.com/minio/minio-go/api-stat.go @@ -47,6 +47,10 @@ func (c Client) BucketExists(bucketName string) (bool, error) { return false, err } if resp != nil { + resperr := httpRespToErrorResponse(resp, bucketName, "") + if ToErrorResponse(resperr).Code == "NoSuchBucket" { + return false, nil + } if resp.StatusCode != http.StatusOK { return false, httpRespToErrorResponse(resp, bucketName, "") } diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go index c69c03edee..9441f4e82d 100644 --- a/vendor/github.com/minio/minio-go/api.go +++ b/vendor/github.com/minio/minio-go/api.go @@ -30,6 +30,7 @@ import ( "math/rand" "net" "net/http" + "net/http/cookiejar" "net/http/httputil" "net/url" "os" @@ -38,6 +39,8 @@ import ( "sync" "time" + "golang.org/x/net/publicsuffix" + "github.com/minio/minio-go/pkg/credentials" "github.com/minio/minio-go/pkg/s3signer" "github.com/minio/minio-go/pkg/s3utils" @@ -99,7 +102,7 @@ type Options struct { // Global constants. const ( libraryName = "minio-go" - libraryVersion = "v6.0.8" + libraryVersion = "v6.0.12" ) // User Agent should always following the below style. @@ -273,6 +276,13 @@ func privateNew(endpoint string, creds *credentials.Credentials, secure bool, re return nil, err } + // Initialize cookies to preserve server sent cookies if any and replay + // them upon each request. + jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) + if err != nil { + return nil, err + } + // instantiate new Client. clnt := new(Client) @@ -287,6 +297,7 @@ func privateNew(endpoint string, creds *credentials.Credentials, secure bool, re // Instantiate http client and bucket location cache. clnt.httpClient = &http.Client{ + Jar: jar, Transport: DefaultTransport, CheckRedirect: clnt.redirectHeaders, } @@ -820,7 +831,7 @@ func (c Client) makeTargetURL(bucketName, objectName, bucketLocation string, isV host = c.s3AccelerateEndpoint } else { // Do not change the host if the endpoint URL is a FIPS S3 endpoint. - if !s3utils.IsAmazonFIPSGovCloudEndpoint(*c.endpointURL) { + if !s3utils.IsAmazonFIPSEndpoint(*c.endpointURL) { // Fetch new host based on the bucket location. host = getS3Endpoint(bucketLocation) } diff --git a/vendor/github.com/minio/minio-go/appveyor.yml b/vendor/github.com/minio/minio-go/appveyor.yml index aa9f840e5b..48ea6e77dc 100644 --- a/vendor/github.com/minio/minio-go/appveyor.yml +++ b/vendor/github.com/minio/minio-go/appveyor.yml @@ -16,7 +16,7 @@ install: - set PATH=%GOPATH%\bin;c:\go\bin;%PATH% - go version - go env - - go get -u github.com/golang/lint/golint + - go get -u golang.org/x/lint/golint - go get -u github.com/remyoudompheng/go-misc/deadcode - go get -u github.com/gordonklaus/ineffassign - go get -u golang.org/x/crypto/argon2 diff --git a/vendor/github.com/minio/minio-go/core.go b/vendor/github.com/minio/minio-go/core.go index 0c651d6000..4d51363f0d 100644 --- a/vendor/github.com/minio/minio-go/core.go +++ b/vendor/github.com/minio/minio-go/core.go @@ -117,11 +117,11 @@ func (c Core) ListObjectParts(bucket, object, uploadID string, partNumberMarker } // CompleteMultipartUpload - Concatenate uploaded parts and commit to an object. -func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) error { - _, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{ +func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) (string, error) { + res, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{ Parts: parts, }) - return err + return res.ETag, err } // AbortMultipartUpload - Abort an incomplete upload. diff --git a/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go b/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go index bfeb73e41a..adceb7f2ab 100644 --- a/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go +++ b/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go @@ -143,11 +143,40 @@ func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool { } // IsAmazonFIPSGovCloudEndpoint - Match if it is exactly Amazon S3 FIPS GovCloud endpoint. +// See https://aws.amazon.com/compliance/fips. func IsAmazonFIPSGovCloudEndpoint(endpointURL url.URL) bool { if endpointURL == sentinelURL { return false } - return endpointURL.Host == "s3-fips-us-gov-west-1.amazonaws.com" + return endpointURL.Host == "s3-fips-us-gov-west-1.amazonaws.com" || + endpointURL.Host == "s3-fips.dualstack.us-gov-west-1.amazonaws.com" +} + +// IsAmazonFIPSUSEastWestEndpoint - Match if it is exactly Amazon S3 FIPS US East/West endpoint. +// See https://aws.amazon.com/compliance/fips. +func IsAmazonFIPSUSEastWestEndpoint(endpointURL url.URL) bool { + if endpointURL == sentinelURL { + return false + } + switch endpointURL.Host { + case "s3-fips.us-east-2.amazonaws.com": + case "s3-fips.dualstack.us-west-1.amazonaws.com": + case "s3-fips.dualstack.us-west-2.amazonaws.com": + case "s3-fips.dualstack.us-east-2.amazonaws.com": + case "s3-fips.dualstack.us-east-1.amazonaws.com": + case "s3-fips.us-west-1.amazonaws.com": + case "s3-fips.us-west-2.amazonaws.com": + case "s3-fips.us-east-1.amazonaws.com": + default: + return false + } + return true +} + +// IsAmazonFIPSEndpoint - Match if it is exactly Amazon S3 FIPS endpoint. +// See https://aws.amazon.com/compliance/fips. +func IsAmazonFIPSEndpoint(endpointURL url.URL) bool { + return IsAmazonFIPSUSEastWestEndpoint(endpointURL) || IsAmazonFIPSGovCloudEndpoint(endpointURL) } // IsGoogleEndpoint - Match if it is exactly Google cloud storage endpoint. diff --git a/vendor/github.com/minio/minio-go/post-policy.go b/vendor/github.com/minio/minio-go/post-policy.go index b3ae7050a8..c285fdefdf 100644 --- a/vendor/github.com/minio/minio-go/post-policy.go +++ b/vendor/github.com/minio/minio-go/post-policy.go @@ -206,6 +206,28 @@ func (p *PostPolicy) SetUserMetadata(key string, value string) error { return nil } +// SetUserData - Set user data as a key/value couple. +// Can be retrieved through a HEAD request or an event. +func (p *PostPolicy) SetUserData(key string, value string) error { + if key == "" { + return ErrInvalidArgument("Key is empty") + } + if value == "" { + return ErrInvalidArgument("Value is empty") + } + headerName := fmt.Sprintf("x-amz-%s", key) + policyCond := policyCondition{ + matchType: "eq", + condition: fmt.Sprintf("$%s", headerName), + value: value, + } + if err := p.addNewPolicy(policyCond); err != nil { + return err + } + p.formData[headerName] = value + return nil +} + // addNewPolicy - internal helper to validate adding new policies. func (p *PostPolicy) addNewPolicy(policyCond policyCondition) error { if policyCond.matchType == "" || policyCond.condition == "" || policyCond.value == "" { diff --git a/vendor/github.com/minio/minio-go/retry.go b/vendor/github.com/minio/minio-go/retry.go index 2a7670786d..445167b6af 100644 --- a/vendor/github.com/minio/minio-go/retry.go +++ b/vendor/github.com/minio/minio-go/retry.go @@ -139,7 +139,7 @@ func isS3CodeRetryable(s3Code string) (ok bool) { // List of HTTP status codes which are retryable. var retryableHTTPStatusCodes = map[int]struct{}{ - 429: {}, // http.StatusTooManyRequests is not part of the Go 1.5 library, yet + 429: {}, // http.StatusTooManyRequests is not part of the Go 1.5 library, yet http.StatusInternalServerError: {}, http.StatusBadGateway: {}, http.StatusServiceUnavailable: {}, diff --git a/vendor/github.com/minio/minio-go/s3-error.go b/vendor/github.com/minio/minio-go/s3-error.go index f9e82334af..3b11776c2c 100644 --- a/vendor/github.com/minio/minio-go/s3-error.go +++ b/vendor/github.com/minio/minio-go/s3-error.go @@ -34,7 +34,7 @@ var s3ErrorResponseMap = map[string]string{ "MissingContentLength": "You must provide the Content-Length HTTP header.", "MissingContentMD5": "Missing required header for this request: Content-Md5.", "MissingRequestBodyError": "Request body is empty.", - "NoSuchBucket": "The specified bucket does not exist", + "NoSuchBucket": "The specified bucket does not exist.", "NoSuchBucketPolicy": "The bucket policy does not exist", "NoSuchKey": "The specified key does not exist.", "NoSuchUpload": "The specified multipart upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.", diff --git a/vendor/vendor.json b/vendor/vendor.json index fe5ca5fea6..5fafe8b52f 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -116,46 +116,46 @@ "revisionTime": "2015-10-24T22:24:27-07:00" }, { - "checksumSHA1": "B4i/KeqYMSaY9QPPYzJpCap6SXk=", + "checksumSHA1": "3wJQ4abLFpfFuy1WbjG+EnCEg2s=", "path": "github.com/minio/minio-go", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "ekYKWG7fBFYuvrhgPxXgo+UJHmM=", "path": "github.com/minio/minio-go/pkg/credentials", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "Md5pOKYfoKtrG7xNvs2FtiDPfDc=", "path": "github.com/minio/minio-go/pkg/encrypt", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "6D/qMFV+e39L+6aeT+Seq1guohM=", "path": "github.com/minio/minio-go/pkg/policy", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "bbWjcrOQsV57qK+BSsrNAsI+Q/o=", "path": "github.com/minio/minio-go/pkg/s3signer", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { - "checksumSHA1": "xrJThFwwkVrJdwd5iYFHqfx4wRY=", + "checksumSHA1": "UQLtl8GIFr1lcHlM7KluYdU3JQg=", "path": "github.com/minio/minio-go/pkg/s3utils", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "Wt8ej+rZXTdNBR9Xyw1eGo3Iq5o=", "path": "github.com/minio/minio-go/pkg/set", - "revision": "14f2b5e6c2562b91ecd8d850ca56b3a8b927e4e7", - "revisionTime": "2018-09-25T09:12:15Z" + "revision": "5f40a0c780086b861984b18f638b4dca4f6897e2", + "revisionTime": "2019-01-02T23:05:50Z" }, { "checksumSHA1": "g8YlJVY8CHJy+N4pAF1522n/Yr8=",