summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/minio
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/minio
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/minio')
-rw-r--r--vendor/github.com/minio/minio-go/api-compose-object_test.go89
-rw-r--r--vendor/github.com/minio/minio-go/api-error-response_test.go294
-rw-r--r--vendor/github.com/minio/minio-go/api-put-object_test.go62
-rw-r--r--vendor/github.com/minio/minio-go/api_unit_test.go209
-rw-r--r--vendor/github.com/minio/minio-go/bucket-cache_test.go351
-rw-r--r--vendor/github.com/minio/minio-go/core_test.go771
-rw-r--r--vendor/github.com/minio/minio-go/docs/API.md1831
-rw-r--r--vendor/github.com/minio/minio-go/docs/checker.go.template21
-rw-r--r--vendor/github.com/minio/minio-go/docs/validator.go227
-rw-r--r--vendor/github.com/minio/minio-go/docs/zh_CN/API.md1820
-rw-r--r--vendor/github.com/minio/minio-go/docs/zh_CN/CONTRIBUTING.md22
-rw-r--r--vendor/github.com/minio/minio-go/examples/minio/listenbucketnotification.go61
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/bucketexists.go52
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/composeobject.go78
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/copyobject.go75
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/fgetobject-context.go54
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/fgetobject.go46
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/fputencrypted-object.go80
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/fputobject-context.go53
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/fputobject.go48
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go89
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/getbucketnotification.go56
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/getbucketpolicy.go56
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/getobject-context.go73
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/getobject.go64
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listbucketpolicies.go57
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listbuckets.go49
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listincompleteuploads.go58
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listobjects-N.go77
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listobjects.go58
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/listobjectsV2.go58
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/makebucket.go47
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/presignedgetobject.go54
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/presignedheadobject.go54
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/presignedpostpolicy.go60
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/presignedputobject.go48
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/put-encrypted-object.go85
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-context.go68
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-getobject-sse.go87
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-progress.go64
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go62
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-streaming.go55
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject.go58
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/removeallbucketnotification.go50
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/removebucket.go49
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/removeincompleteupload.go47
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/removeobject.go46
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/removeobjects.go65
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/setbucketnotification.go86
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/setbucketpolicy.go55
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/statobject.go46
-rw-r--r--vendor/github.com/minio/minio-go/get-options_test.go57
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/chain_test.go144
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/credentials_test.go73
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/env_test.go105
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/file_test.go189
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/iam_aws_test.go197
-rw-r--r--vendor/github.com/minio/minio-go/pkg/credentials/static_test.go68
-rw-r--r--vendor/github.com/minio/minio-go/pkg/policy/bucket-policy-condition_test.go290
-rw-r--r--vendor/github.com/minio/minio-go/pkg/policy/bucket-policy_test.go1823
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go109
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go36
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go50
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go71
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go104
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go75
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3utils/utils_test.go408
-rw-r--r--vendor/github.com/minio/minio-go/pkg/set/stringset_test.go348
-rw-r--r--vendor/github.com/minio/minio-go/test-utils_test.go75
-rw-r--r--vendor/github.com/minio/minio-go/utils_test.go403
70 files changed, 0 insertions, 12750 deletions
diff --git a/vendor/github.com/minio/minio-go/api-compose-object_test.go b/vendor/github.com/minio/minio-go/api-compose-object_test.go
deleted file mode 100644
index 0f22a960b..000000000
--- a/vendor/github.com/minio/minio-go/api-compose-object_test.go
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 minio
-
-import (
- "reflect"
- "testing"
-)
-
-const (
- gb1 = 1024 * 1024 * 1024
- gb5 = 5 * gb1
- gb5p1 = gb5 + 1
- gb10p1 = 2*gb5 + 1
- gb10p2 = 2*gb5 + 2
-)
-
-func TestPartsRequired(t *testing.T) {
- testCases := []struct {
- size, ref int64
- }{
- {0, 0},
- {1, 1},
- {gb5, 1},
- {2 * gb5, 2},
- {gb10p1, 3},
- {gb10p2, 3},
- }
-
- for i, testCase := range testCases {
- res := partsRequired(testCase.size)
- if res != testCase.ref {
- t.Errorf("Test %d - output did not match with reference results", i+1)
- }
- }
-}
-
-func TestCalculateEvenSplits(t *testing.T) {
-
- testCases := []struct {
- // input size and source object
- size int64
- src SourceInfo
-
- // output part-indexes
- starts, ends []int64
- }{
- {0, SourceInfo{start: -1}, nil, nil},
- {1, SourceInfo{start: -1}, []int64{0}, []int64{0}},
- {1, SourceInfo{start: 0}, []int64{0}, []int64{0}},
-
- {gb1, SourceInfo{start: -1}, []int64{0}, []int64{gb1 - 1}},
- {gb5, SourceInfo{start: -1}, []int64{0}, []int64{gb5 - 1}},
-
- // 2 part splits
- {gb5p1, SourceInfo{start: -1}, []int64{0, gb5/2 + 1}, []int64{gb5 / 2, gb5}},
- {gb5p1, SourceInfo{start: -1}, []int64{0, gb5/2 + 1}, []int64{gb5 / 2, gb5}},
-
- // 3 part splits
- {gb10p1, SourceInfo{start: -1},
- []int64{0, gb10p1/3 + 1, 2*gb10p1/3 + 1},
- []int64{gb10p1 / 3, 2 * gb10p1 / 3, gb10p1 - 1}},
-
- {gb10p2, SourceInfo{start: -1},
- []int64{0, gb10p2 / 3, 2 * gb10p2 / 3},
- []int64{gb10p2/3 - 1, 2*gb10p2/3 - 1, gb10p2 - 1}},
- }
-
- for i, testCase := range testCases {
- resStart, resEnd := calculateEvenSplits(testCase.size, testCase.src)
- if !reflect.DeepEqual(testCase.starts, resStart) || !reflect.DeepEqual(testCase.ends, resEnd) {
- t.Errorf("Test %d - output did not match with reference results", i+1)
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/api-error-response_test.go b/vendor/github.com/minio/minio-go/api-error-response_test.go
deleted file mode 100644
index bf10941b4..000000000
--- a/vendor/github.com/minio/minio-go/api-error-response_test.go
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 minio
-
-import (
- "bytes"
- "encoding/xml"
- "fmt"
- "io/ioutil"
- "net/http"
- "reflect"
- "strconv"
- "testing"
-)
-
-// Tests validate the Error generator function for http response with error.
-func TestHttpRespToErrorResponse(t *testing.T) {
- // 'genAPIErrorResponse' generates ErrorResponse for given APIError.
- // provides a encodable populated response values.
- genAPIErrorResponse := func(err APIError, bucketName string) ErrorResponse {
- return ErrorResponse{
- Code: err.Code,
- Message: err.Description,
- BucketName: bucketName,
- }
- }
-
- // Encodes the response headers into XML format.
- encodeErr := func(response ErrorResponse) []byte {
- buf := &bytes.Buffer{}
- buf.WriteString(xml.Header)
- encoder := xml.NewEncoder(buf)
- err := encoder.Encode(response)
- if err != nil {
- t.Fatalf("error encoding response: %v", err)
- }
- return buf.Bytes()
- }
-
- // `createAPIErrorResponse` Mocks XML error response from the server.
- createAPIErrorResponse := func(APIErr APIError, bucketName string) *http.Response {
- // generate error response.
- // response body contains the XML error message.
- resp := &http.Response{}
- errorResponse := genAPIErrorResponse(APIErr, bucketName)
- encodedErrorResponse := encodeErr(errorResponse)
- // write Header.
- resp.StatusCode = APIErr.HTTPStatusCode
- resp.Body = ioutil.NopCloser(bytes.NewBuffer(encodedErrorResponse))
-
- return resp
- }
-
- // 'genErrResponse' contructs error response based http Status Code
- genErrResponse := func(resp *http.Response, code, message, bucketName, objectName string) ErrorResponse {
- errResp := ErrorResponse{
- StatusCode: resp.StatusCode,
- Code: code,
- Message: message,
- BucketName: bucketName,
- Key: objectName,
- RequestID: resp.Header.Get("x-amz-request-id"),
- HostID: resp.Header.Get("x-amz-id-2"),
- Region: resp.Header.Get("x-amz-bucket-region"),
- Headers: resp.Header,
- }
- return errResp
- }
-
- // Generate invalid argument error.
- genInvalidError := func(message string) error {
- errResp := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "InvalidArgument",
- Message: message,
- RequestID: "minio",
- }
- return errResp
- }
-
- // Set common http response headers.
- setCommonHeaders := func(resp *http.Response) *http.Response {
- // set headers.
- resp.Header = make(http.Header)
- resp.Header.Set("x-amz-request-id", "xyz")
- resp.Header.Set("x-amz-id-2", "abc")
- resp.Header.Set("x-amz-bucket-region", "us-east-1")
- return resp
- }
-
- // Generate http response with empty body.
- // Set the StatusCode to the argument supplied.
- // Sets common headers.
- genEmptyBodyResponse := func(statusCode int) *http.Response {
- resp := &http.Response{
- StatusCode: statusCode,
- Body: ioutil.NopCloser(bytes.NewReader(nil)),
- }
- setCommonHeaders(resp)
- return resp
- }
-
- // Decode XML error message from the http response body.
- decodeXMLError := func(resp *http.Response) error {
- errResp := ErrorResponse{
- StatusCode: resp.StatusCode,
- }
- err := xmlDecoder(resp.Body, &errResp)
- if err != nil {
- t.Fatalf("XML decoding of response body failed: %v", err)
- }
- return errResp
- }
-
- // List of APIErrors used to generate/mock server side XML error response.
- APIErrors := []APIError{
- {
- Code: "NoSuchBucketPolicy",
- Description: "The specified bucket does not have a bucket policy.",
- HTTPStatusCode: http.StatusNotFound,
- },
- }
-
- // List of expected response.
- // Used for asserting the actual response.
- expectedErrResponse := []error{
- genInvalidError("Response is empty. " + "Please report this issue at https://github.com/minio/minio-go/issues."),
- decodeXMLError(createAPIErrorResponse(APIErrors[0], "minio-bucket")),
- genErrResponse(setCommonHeaders(&http.Response{StatusCode: http.StatusNotFound}), "NoSuchBucket", "The specified bucket does not exist.", "minio-bucket", ""),
- genErrResponse(setCommonHeaders(&http.Response{StatusCode: http.StatusNotFound}), "NoSuchKey", "The specified key does not exist.", "minio-bucket", "Asia/"),
- genErrResponse(setCommonHeaders(&http.Response{StatusCode: http.StatusForbidden}), "AccessDenied", "Access Denied.", "minio-bucket", ""),
- genErrResponse(setCommonHeaders(&http.Response{StatusCode: http.StatusConflict}), "Conflict", "Bucket not empty.", "minio-bucket", ""),
- genErrResponse(setCommonHeaders(&http.Response{StatusCode: http.StatusBadRequest}), "Bad Request", "Bad Request", "minio-bucket", ""),
- }
-
- // List of http response to be used as input.
- inputResponses := []*http.Response{
- nil,
- createAPIErrorResponse(APIErrors[0], "minio-bucket"),
- genEmptyBodyResponse(http.StatusNotFound),
- genEmptyBodyResponse(http.StatusNotFound),
- genEmptyBodyResponse(http.StatusForbidden),
- genEmptyBodyResponse(http.StatusConflict),
- genEmptyBodyResponse(http.StatusBadRequest),
- }
-
- testCases := []struct {
- bucketName string
- objectName string
- inputHTTPResp *http.Response
- // expected results.
- expectedResult error
- // flag indicating whether tests should pass.
-
- }{
- {"minio-bucket", "", inputResponses[0], expectedErrResponse[0]},
- {"minio-bucket", "", inputResponses[1], expectedErrResponse[1]},
- {"minio-bucket", "", inputResponses[2], expectedErrResponse[2]},
- {"minio-bucket", "Asia/", inputResponses[3], expectedErrResponse[3]},
- {"minio-bucket", "", inputResponses[4], expectedErrResponse[4]},
- {"minio-bucket", "", inputResponses[5], expectedErrResponse[5]},
- }
-
- for i, testCase := range testCases {
- actualResult := httpRespToErrorResponse(testCase.inputHTTPResp, testCase.bucketName, testCase.objectName)
- if !reflect.DeepEqual(testCase.expectedResult, actualResult) {
- t.Errorf("Test %d: Expected result to be '%#v', but instead got '%#v'", i+1, testCase.expectedResult, actualResult)
- }
- }
-}
-
-// Test validates 'ErrEntityTooLarge' error response.
-func TestErrEntityTooLarge(t *testing.T) {
- msg := fmt.Sprintf("Your proposed upload size ‘%d’ exceeds the maximum allowed object size ‘%d’ for single PUT operation.", 1000000, 99999)
- expectedResult := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "EntityTooLarge",
- Message: msg,
- BucketName: "minio-bucket",
- Key: "Asia/",
- }
- actualResult := ErrEntityTooLarge(1000000, 99999, "minio-bucket", "Asia/")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Test validates 'ErrEntityTooSmall' error response.
-func TestErrEntityTooSmall(t *testing.T) {
- msg := fmt.Sprintf("Your proposed upload size ‘%d’ is below the minimum allowed object size ‘0B’ for single PUT operation.", -1)
- expectedResult := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "EntityTooSmall",
- Message: msg,
- BucketName: "minio-bucket",
- Key: "Asia/",
- }
- actualResult := ErrEntityTooSmall(-1, "minio-bucket", "Asia/")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Test validates 'ErrUnexpectedEOF' error response.
-func TestErrUnexpectedEOF(t *testing.T) {
- msg := fmt.Sprintf("Data read ‘%s’ is not equal to the size ‘%s’ of the input Reader.",
- strconv.FormatInt(100, 10), strconv.FormatInt(101, 10))
- expectedResult := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "UnexpectedEOF",
- Message: msg,
- BucketName: "minio-bucket",
- Key: "Asia/",
- }
- actualResult := ErrUnexpectedEOF(100, 101, "minio-bucket", "Asia/")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Test validates 'ErrInvalidBucketName' error response.
-func TestErrInvalidBucketName(t *testing.T) {
- expectedResult := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "InvalidBucketName",
- Message: "Invalid Bucket name",
- RequestID: "minio",
- }
- actualResult := ErrInvalidBucketName("Invalid Bucket name")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Test validates 'ErrInvalidObjectName' error response.
-func TestErrInvalidObjectName(t *testing.T) {
- expectedResult := ErrorResponse{
- StatusCode: http.StatusNotFound,
- Code: "NoSuchKey",
- Message: "Invalid Object Key",
- RequestID: "minio",
- }
- actualResult := ErrInvalidObjectName("Invalid Object Key")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Test validates 'ErrInvalidArgument' response.
-func TestErrInvalidArgument(t *testing.T) {
- expectedResult := ErrorResponse{
- StatusCode: http.StatusBadRequest,
- Code: "InvalidArgument",
- Message: "Invalid Argument",
- RequestID: "minio",
- }
- actualResult := ErrInvalidArgument("Invalid Argument")
- if !reflect.DeepEqual(expectedResult, actualResult) {
- t.Errorf("Expected result to be '%#v', but instead got '%#v'", expectedResult, actualResult)
- }
-}
-
-// Tests if the Message field is missing.
-func TestErrWithoutMessage(t *testing.T) {
- errResp := ErrorResponse{
- Code: "AccessDenied",
- RequestID: "minio",
- }
- if errResp.Error() != "Access Denied." {
- t.Errorf("Expected \"Access Denied.\", got %s", errResp)
- }
- errResp = ErrorResponse{
- Code: "InvalidArgument",
- RequestID: "minio",
- }
- if errResp.Error() != "Error response code InvalidArgument." {
- t.Errorf("Expected \"Error response code InvalidArgument.\", got %s", errResp)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/api-put-object_test.go b/vendor/github.com/minio/minio-go/api-put-object_test.go
deleted file mode 100644
index 2b8c1e2bb..000000000
--- a/vendor/github.com/minio/minio-go/api-put-object_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 minio
-
-import (
- "testing"
-)
-
-func TestPutObjectOptionsValidate(t *testing.T) {
- testCases := []struct {
- name, value string
- shouldPass bool
- }{
- // Invalid cases.
- {"X-Amz-Matdesc", "blah", false},
- {"x-amz-meta-X-Amz-Iv", "blah", false},
- {"x-amz-meta-X-Amz-Key", "blah", false},
- {"x-amz-meta-X-Amz-Matdesc", "blah", false},
- {"It has spaces", "v", false},
- {"It,has@illegal=characters", "v", false},
- {"X-Amz-Iv", "blah", false},
- {"X-Amz-Key", "blah", false},
- {"X-Amz-Key-prefixed-header", "blah", false},
- {"Content-Type", "custom/content-type", false},
- {"content-type", "custom/content-type", false},
- {"Content-Encoding", "gzip", false},
- {"Cache-Control", "blah", false},
- {"Content-Disposition", "something", false},
-
- // Valid metadata names.
- {"my-custom-header", "blah", true},
- {"custom-X-Amz-Key-middle", "blah", true},
- {"my-custom-header-X-Amz-Key", "blah", true},
- {"blah-X-Amz-Matdesc", "blah", true},
- {"X-Amz-MatDesc-suffix", "blah", true},
- {"It-Is-Fine", "v", true},
- {"Numbers-098987987-Should-Work", "v", true},
- {"Crazy-!#$%&'*+-.^_`|~-Should-193832-Be-Fine", "v", true},
- }
- for i, testCase := range testCases {
- err := PutObjectOptions{UserMetadata: map[string]string{
- testCase.name: testCase.value,
- }}.validate()
- if testCase.shouldPass && err != nil {
- t.Errorf("Test %d - output did not match with reference results, %s", i+1, err)
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/api_unit_test.go b/vendor/github.com/minio/minio-go/api_unit_test.go
deleted file mode 100644
index ee0b54f5c..000000000
--- a/vendor/github.com/minio/minio-go/api_unit_test.go
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 minio
-
-import (
- "net/http"
- "net/url"
- "testing"
-
- "github.com/minio/minio-go/pkg/credentials"
- "github.com/minio/minio-go/pkg/policy"
-)
-
-type customReader struct{}
-
-func (c *customReader) Read(p []byte) (n int, err error) {
- return 0, nil
-}
-
-func (c *customReader) Size() (n int64) {
- return 10
-}
-
-// Tests valid hosts for location.
-func TestValidBucketLocation(t *testing.T) {
- s3Hosts := []struct {
- bucketLocation string
- endpoint string
- }{
- {"us-east-1", "s3.amazonaws.com"},
- {"unknown", "s3.amazonaws.com"},
- {"ap-southeast-1", "s3-ap-southeast-1.amazonaws.com"},
- }
- for _, s3Host := range s3Hosts {
- endpoint := getS3Endpoint(s3Host.bucketLocation)
- if endpoint != s3Host.endpoint {
- t.Fatal("Error: invalid bucket location", endpoint)
- }
- }
-}
-
-// Tests error response structure.
-func TestErrorResponse(t *testing.T) {
- var err error
- err = ErrorResponse{
- Code: "Testing",
- }
- errResp := ToErrorResponse(err)
- if errResp.Code != "Testing" {
- t.Fatal("Type conversion failed, we have an empty struct.")
- }
-
- // Test http response decoding.
- var httpResponse *http.Response
- // Set empty variables
- httpResponse = nil
- var bucketName, objectName string
-
- // Should fail with invalid argument.
- err = httpRespToErrorResponse(httpResponse, bucketName, objectName)
- errResp = ToErrorResponse(err)
- if errResp.Code != "InvalidArgument" {
- t.Fatal("Empty response input should return invalid argument.")
- }
-}
-
-// Tests signature type.
-func TestSignatureType(t *testing.T) {
- clnt := Client{}
- if !clnt.overrideSignerType.IsV4() {
- t.Fatal("Error")
- }
- clnt.overrideSignerType = credentials.SignatureV2
- if !clnt.overrideSignerType.IsV2() {
- t.Fatal("Error")
- }
- if clnt.overrideSignerType.IsV4() {
- t.Fatal("Error")
- }
- clnt.overrideSignerType = credentials.SignatureV4
- if !clnt.overrideSignerType.IsV4() {
- t.Fatal("Error")
- }
-}
-
-// Tests bucket policy types.
-func TestBucketPolicyTypes(t *testing.T) {
- want := map[string]bool{
- "none": true,
- "readonly": true,
- "writeonly": true,
- "readwrite": true,
- "invalid": false,
- }
- for bucketPolicy, ok := range want {
- if policy.BucketPolicy(bucketPolicy).IsValidBucketPolicy() != ok {
- t.Fatal("Error")
- }
- }
-}
-
-// Tests optimal part size.
-func TestPartSize(t *testing.T) {
- _, _, _, err := optimalPartInfo(5000000000000000000)
- if err == nil {
- t.Fatal("Error: should fail")
- }
- totalPartsCount, partSize, lastPartSize, err := optimalPartInfo(5497558138880)
- if err != nil {
- t.Fatal("Error: ", err)
- }
- if totalPartsCount != 9103 {
- t.Fatalf("Error: expecting total parts count of 9987: got %v instead", totalPartsCount)
- }
- if partSize != 603979776 {
- t.Fatalf("Error: expecting part size of 550502400: got %v instead", partSize)
- }
- if lastPartSize != 134217728 {
- t.Fatalf("Error: expecting last part size of 241172480: got %v instead", lastPartSize)
- }
- _, partSize, _, err = optimalPartInfo(5000000000)
- if err != nil {
- t.Fatal("Error:", err)
- }
- if partSize != minPartSize {
- t.Fatalf("Error: expecting part size of %v: got %v instead", minPartSize, partSize)
- }
- totalPartsCount, partSize, lastPartSize, err = optimalPartInfo(-1)
- if err != nil {
- t.Fatal("Error:", err)
- }
- if totalPartsCount != 9103 {
- t.Fatalf("Error: expecting total parts count of 9987: got %v instead", totalPartsCount)
- }
- if partSize != 603979776 {
- t.Fatalf("Error: expecting part size of 550502400: got %v instead", partSize)
- }
- if lastPartSize != 134217728 {
- t.Fatalf("Error: expecting last part size of 241172480: got %v instead", lastPartSize)
- }
-}
-
-// TestMakeTargetURL - testing makeTargetURL()
-func TestMakeTargetURL(t *testing.T) {
- testCases := []struct {
- addr string
- secure bool
- bucketName string
- objectName string
- bucketLocation string
- queryValues map[string][]string
- expectedURL url.URL
- expectedErr error
- }{
- // Test 1
- {"localhost:9000", false, "", "", "", nil, url.URL{Host: "localhost:9000", Scheme: "http", Path: "/"}, nil},
- // Test 2
- {"localhost", true, "", "", "", nil, url.URL{Host: "localhost", Scheme: "https", Path: "/"}, nil},
- // Test 3
- {"localhost:9000", true, "mybucket", "", "", nil, url.URL{Host: "localhost:9000", Scheme: "https", Path: "/mybucket/"}, nil},
- // Test 4, testing against google storage API
- {"storage.googleapis.com", true, "mybucket", "", "", nil, url.URL{Host: "mybucket.storage.googleapis.com", Scheme: "https", Path: "/"}, nil},
- // Test 5, testing against AWS S3 API
- {"s3.amazonaws.com", true, "mybucket", "myobject", "", nil, url.URL{Host: "mybucket.s3.amazonaws.com", Scheme: "https", Path: "/myobject"}, nil},
- // Test 6
- {"localhost:9000", false, "mybucket", "myobject", "", nil, url.URL{Host: "localhost:9000", Scheme: "http", Path: "/mybucket/myobject"}, nil},
- // Test 7, testing with query
- {"localhost:9000", false, "mybucket", "myobject", "", map[string][]string{"param": {"val"}}, url.URL{Host: "localhost:9000", Scheme: "http", Path: "/mybucket/myobject", RawQuery: "param=val"}, nil},
- // Test 8, testing with port 80
- {"localhost:80", false, "mybucket", "myobject", "", nil, url.URL{Host: "localhost", Scheme: "http", Path: "/mybucket/myobject"}, nil},
- // Test 9, testing with port 443
- {"localhost:443", true, "mybucket", "myobject", "", nil, url.URL{Host: "localhost", Scheme: "https", Path: "/mybucket/myobject"}, nil},
- }
-
- for i, testCase := range testCases {
- // Initialize a Minio client
- c, _ := New(testCase.addr, "foo", "bar", testCase.secure)
- u, err := c.makeTargetURL(testCase.bucketName, testCase.objectName, testCase.bucketLocation, testCase.queryValues)
- // Check the returned error
- if testCase.expectedErr == nil && err != nil {
- t.Fatalf("Test %d: Should succeed but failed with err = %v", i+1, err)
- }
- if testCase.expectedErr != nil && err == nil {
- t.Fatalf("Test %d: Should fail but succeeded", i+1)
- }
- if err == nil {
- // Check if the returned url is equal to what we expect
- if u.String() != testCase.expectedURL.String() {
- t.Fatalf("Test %d: Mismatched target url: expected = `%v`, found = `%v`",
- i+1, testCase.expectedURL.String(), u.String())
- }
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/bucket-cache_test.go b/vendor/github.com/minio/minio-go/bucket-cache_test.go
deleted file mode 100644
index fd7e7f344..000000000
--- a/vendor/github.com/minio/minio-go/bucket-cache_test.go
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright
- * 2015, 2016, 2017 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 minio
-
-import (
- "bytes"
- "encoding/xml"
- "io/ioutil"
- "net/http"
- "net/url"
- "path"
- "reflect"
- "testing"
-
- "github.com/minio/minio-go/pkg/credentials"
- "github.com/minio/minio-go/pkg/s3signer"
-)
-
-// Test validates `newBucketLocationCache`.
-func TestNewBucketLocationCache(t *testing.T) {
- expectedBucketLocationcache := &bucketLocationCache{
- items: make(map[string]string),
- }
- actualBucketLocationCache := newBucketLocationCache()
-
- if !reflect.DeepEqual(actualBucketLocationCache, expectedBucketLocationcache) {
- t.Errorf("Unexpected return value")
- }
-}
-
-// Tests validate bucketLocationCache operations.
-func TestBucketLocationCacheOps(t *testing.T) {
- testBucketLocationCache := newBucketLocationCache()
- expectedBucketName := "minio-bucket"
- expectedLocation := "us-east-1"
- testBucketLocationCache.Set(expectedBucketName, expectedLocation)
- actualLocation, ok := testBucketLocationCache.Get(expectedBucketName)
- if !ok {
- t.Errorf("Bucket location cache not set")
- }
- if expectedLocation != actualLocation {
- t.Errorf("Bucket location cache not set to expected value")
- }
- testBucketLocationCache.Delete(expectedBucketName)
- _, ok = testBucketLocationCache.Get(expectedBucketName)
- if ok {
- t.Errorf("Bucket location cache not deleted as expected")
- }
-}
-
-// Tests validate http request generation for 'getBucketLocation'.
-func TestGetBucketLocationRequest(t *testing.T) {
- // Generates expected http request for getBucketLocation.
- // Used for asserting with the actual request generated.
- createExpectedRequest := func(c *Client, bucketName string, req *http.Request) (*http.Request, error) {
- // Set location query.
- urlValues := make(url.Values)
- urlValues.Set("location", "")
-
- // Set get bucket location always as path style.
- targetURL := c.endpointURL
- targetURL.Path = path.Join(bucketName, "") + "/"
- targetURL.RawQuery = urlValues.Encode()
-
- // Get a new HTTP request for the method.
- var err error
- req, err = http.NewRequest("GET", targetURL.String(), nil)
- if err != nil {
- return nil, err
- }
-
- // Set UserAgent for the request.
- c.setUserAgent(req)
-
- // Get credentials from the configured credentials provider.
- value, err := c.credsProvider.Get()
- if err != nil {
- return nil, err
- }
-
- var (
- signerType = value.SignerType
- accessKeyID = value.AccessKeyID
- secretAccessKey = value.SecretAccessKey
- sessionToken = value.SessionToken
- )
-
- // Custom signer set then override the behavior.
- if c.overrideSignerType != credentials.SignatureDefault {
- signerType = c.overrideSignerType
- }
-
- // If signerType returned by credentials helper is anonymous,
- // then do not sign regardless of signerType override.
- if value.SignerType == credentials.SignatureAnonymous {
- signerType = credentials.SignatureAnonymous
- }
-
- // Set sha256 sum for signature calculation only
- // with signature version '4'.
- switch {
- case signerType.IsV4():
- contentSha256 := emptySHA256Hex
- if c.secure {
- contentSha256 = unsignedPayload
- }
- req.Header.Set("X-Amz-Content-Sha256", contentSha256)
- req = s3signer.SignV4(*req, accessKeyID, secretAccessKey, sessionToken, "us-east-1")
- case signerType.IsV2():
- req = s3signer.SignV2(*req, accessKeyID, secretAccessKey)
- }
-
- return req, nil
-
- }
- // Info for 'Client' creation.
- // Will be used as arguments for 'NewClient'.
- type infoForClient struct {
- endPoint string
- accessKey string
- secretKey string
- enableInsecure bool
- }
- // dataset for 'NewClient' call.
- info := []infoForClient{
- // endpoint localhost.
- // both access-key and secret-key are empty.
- {"localhost:9000", "", "", false},
- // both access-key are secret-key exists.
- {"localhost:9000", "my-access-key", "my-secret-key", false},
- // one of acess-key and secret-key are empty.
- {"localhost:9000", "", "my-secret-key", false},
-
- // endpoint amazon s3.
- {"s3.amazonaws.com", "", "", false},
- {"s3.amazonaws.com", "my-access-key", "my-secret-key", false},
- {"s3.amazonaws.com", "my-acess-key", "", false},
-
- // endpoint google cloud storage.
- {"storage.googleapis.com", "", "", false},
- {"storage.googleapis.com", "my-access-key", "my-secret-key", false},
- {"storage.googleapis.com", "", "my-secret-key", false},
-
- // endpoint custom domain running Minio server.
- {"play.minio.io", "", "", false},
- {"play.minio.io", "my-access-key", "my-secret-key", false},
- {"play.minio.io", "my-acess-key", "", false},
- }
- testCases := []struct {
- bucketName string
- // data for new client creation.
- info infoForClient
- // error in the output.
- err error
- // flag indicating whether tests should pass.
- shouldPass bool
- }{
- // Client is constructed using the info struct.
- // case with empty location.
- {"my-bucket", info[0], nil, true},
- // case with location set to standard 'us-east-1'.
- {"my-bucket", info[0], nil, true},
- // case with location set to a value different from 'us-east-1'.
- {"my-bucket", info[0], nil, true},
-
- {"my-bucket", info[1], nil, true},
- {"my-bucket", info[1], nil, true},
- {"my-bucket", info[1], nil, true},
-
- {"my-bucket", info[2], nil, true},
- {"my-bucket", info[2], nil, true},
- {"my-bucket", info[2], nil, true},
-
- {"my-bucket", info[3], nil, true},
- {"my-bucket", info[3], nil, true},
- {"my-bucket", info[3], nil, true},
-
- {"my-bucket", info[4], nil, true},
- {"my-bucket", info[4], nil, true},
- {"my-bucket", info[4], nil, true},
-
- {"my-bucket", info[5], nil, true},
- {"my-bucket", info[5], nil, true},
- {"my-bucket", info[5], nil, true},
-
- {"my-bucket", info[6], nil, true},
- {"my-bucket", info[6], nil, true},
- {"my-bucket", info[6], nil, true},
-
- {"my-bucket", info[7], nil, true},
- {"my-bucket", info[7], nil, true},
- {"my-bucket", info[7], nil, true},
-
- {"my-bucket", info[8], nil, true},
- {"my-bucket", info[8], nil, true},
- {"my-bucket", info[8], nil, true},
-
- {"my-bucket", info[9], nil, true},
- {"my-bucket", info[9], nil, true},
- {"my-bucket", info[9], nil, true},
-
- {"my-bucket", info[10], nil, true},
- {"my-bucket", info[10], nil, true},
- {"my-bucket", info[10], nil, true},
-
- {"my-bucket", info[11], nil, true},
- {"my-bucket", info[11], nil, true},
- {"my-bucket", info[11], nil, true},
- }
- for i, testCase := range testCases {
- // cannot create a newclient with empty endPoint value.
- // validates and creates a new client only if the endPoint value is not empty.
- client := &Client{}
- var err error
- if testCase.info.endPoint != "" {
-
- client, err = New(testCase.info.endPoint, testCase.info.accessKey, testCase.info.secretKey, testCase.info.enableInsecure)
- if err != nil {
- t.Fatalf("Test %d: Failed to create new Client: %s", i+1, err.Error())
- }
- }
-
- actualReq, err := client.getBucketLocationRequest(testCase.bucketName)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- // Test passes as expected, but the output values are verified for correctness here.
- if err == nil && testCase.shouldPass {
- expectedReq := &http.Request{}
- expectedReq, err = createExpectedRequest(client, testCase.bucketName, expectedReq)
- if err != nil {
- t.Fatalf("Test %d: Expected request Creation failed", i+1)
- }
- if expectedReq.Method != actualReq.Method {
- t.Errorf("Test %d: The expected Request method doesn't match with the actual one", i+1)
- }
- if expectedReq.URL.String() != actualReq.URL.String() {
- t.Errorf("Test %d: Expected the request URL to be '%s', but instead found '%s'", i+1, expectedReq.URL.String(), actualReq.URL.String())
- }
- if expectedReq.ContentLength != actualReq.ContentLength {
- t.Errorf("Test %d: Expected the request body Content-Length to be '%d', but found '%d' instead", i+1, expectedReq.ContentLength, actualReq.ContentLength)
- }
-
- if expectedReq.Header.Get("X-Amz-Content-Sha256") != actualReq.Header.Get("X-Amz-Content-Sha256") {
- t.Errorf("Test %d: 'X-Amz-Content-Sha256' header of the expected request doesn't match with that of the actual request", i+1)
- }
- if expectedReq.Header.Get("User-Agent") != actualReq.Header.Get("User-Agent") {
- t.Errorf("Test %d: Expected 'User-Agent' header to be \"%s\",but found \"%s\" instead", i+1, expectedReq.Header.Get("User-Agent"), actualReq.Header.Get("User-Agent"))
- }
- }
- }
-}
-
-// generates http response with bucket location set in the body.
-func generateLocationResponse(resp *http.Response, bodyContent []byte) (*http.Response, error) {
- resp.StatusCode = http.StatusOK
- resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyContent))
- return resp, nil
-}
-
-// Tests the processing of GetPolicy response from server.
-func TestProcessBucketLocationResponse(t *testing.T) {
- // 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"`
- }
-
- APIErrors := []APIError{
- {
- Code: "AccessDenied",
- Description: "Access Denied",
- HTTPStatusCode: http.StatusUnauthorized,
- },
- }
- testCases := []struct {
- bucketName string
- inputLocation string
- isAPIError bool
- apiErr APIError
- // expected results.
- expectedResult string
- err error
- // flag indicating whether tests should pass.
- shouldPass bool
- }{
- {"my-bucket", "", true, APIErrors[0], "us-east-1", nil, true},
- {"my-bucket", "", false, APIError{}, "us-east-1", nil, true},
- {"my-bucket", "EU", false, APIError{}, "eu-west-1", nil, true},
- {"my-bucket", "eu-central-1", false, APIError{}, "eu-central-1", nil, true},
- {"my-bucket", "us-east-1", false, APIError{}, "us-east-1", nil, true},
- }
-
- for i, testCase := range testCases {
- inputResponse := &http.Response{}
- var err error
- if testCase.isAPIError {
- inputResponse = generateErrorResponse(inputResponse, testCase.apiErr, testCase.bucketName)
- } else {
- inputResponse, err = generateLocationResponse(inputResponse, encodeResponse(LocationResponse{
- Location: testCase.inputLocation,
- }))
- if err != nil {
- t.Fatalf("Test %d: Creation of valid response failed", i+1)
- }
- }
- actualResult, err := processBucketLocationResponse(inputResponse, "my-bucket")
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
- if err == nil && testCase.shouldPass {
- if !reflect.DeepEqual(testCase.expectedResult, actualResult) {
- t.Errorf("Test %d: The expected BucketPolicy doesn't match the actual BucketPolicy", i+1)
- }
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/core_test.go b/vendor/github.com/minio/minio-go/core_test.go
deleted file mode 100644
index 8cf810465..000000000
--- a/vendor/github.com/minio/minio-go/core_test.go
+++ /dev/null
@@ -1,771 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 minio
-
-import (
- "bytes"
- "io"
- "log"
- "os"
- "reflect"
- "testing"
- "time"
-
- "math/rand"
-)
-
-const (
- serverEndpoint = "SERVER_ENDPOINT"
- accessKey = "ACCESS_KEY"
- secretKey = "SECRET_KEY"
- enableSecurity = "ENABLE_HTTPS"
-)
-
-// Minimum part size
-const MinPartSize = 1024 * 1024 * 64
-const letterBytes = "abcdefghijklmnopqrstuvwxyz01234569"
-const (
- letterIdxBits = 6 // 6 bits to represent a letter index
- letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
- letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
-)
-
-// randString generates random names and prepends them with a known prefix.
-func randString(n int, src rand.Source, prefix string) string {
- b := make([]byte, n)
- // A rand.Int63() generates 63 random bits, enough for letterIdxMax letters!
- for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
- if remain == 0 {
- cache, remain = src.Int63(), letterIdxMax
- }
- if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
- b[i] = letterBytes[idx]
- i--
- }
- cache >>= letterIdxBits
- remain--
- }
- return prefix + string(b[0:30-len(prefix)])
-}
-
-// Tests for Core GetObject() function.
-func TestGetObjectCore(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for the short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio core client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable tracing, write to stderr.
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- // Generate data more than 32K
- buf := bytes.Repeat([]byte("3"), rand.Intn(1<<20)+32*1024)
-
- // Save the data
- objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
- n, err := c.Client.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), PutObjectOptions{
- ContentType: "binary/octet-stream",
- })
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if n != int64(len(buf)) {
- t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), n)
- }
-
- offset := int64(2048)
-
- // read directly
- buf1 := make([]byte, 512)
- buf2 := make([]byte, 512)
- buf3 := make([]byte, n)
- buf4 := make([]byte, 1)
-
- opts := GetObjectOptions{}
- opts.SetRange(offset, offset+int64(len(buf1))-1)
- reader, objectInfo, err := c.GetObject(bucketName, objectName, opts)
- if err != nil {
- t.Fatal(err)
- }
- m, err := io.ReadFull(reader, buf1)
- reader.Close()
- if err != nil {
- t.Fatal(err)
- }
-
- if objectInfo.Size != int64(m) {
- t.Fatalf("Error: GetObject read shorter bytes before reaching EOF, want %v, got %v\n", objectInfo.Size, m)
- }
- if !bytes.Equal(buf1, buf[offset:offset+512]) {
- t.Fatal("Error: Incorrect read between two GetObject from same offset.")
- }
- offset += 512
-
- opts.SetRange(offset, offset+int64(len(buf2))-1)
- reader, objectInfo, err = c.GetObject(bucketName, objectName, opts)
- if err != nil {
- t.Fatal(err)
- }
-
- m, err = io.ReadFull(reader, buf2)
- reader.Close()
- if err != nil {
- t.Fatal(err)
- }
-
- if objectInfo.Size != int64(m) {
- t.Fatalf("Error: GetObject read shorter bytes before reaching EOF, want %v, got %v\n", objectInfo.Size, m)
- }
- if !bytes.Equal(buf2, buf[offset:offset+512]) {
- t.Fatal("Error: Incorrect read between two GetObject from same offset.")
- }
-
- opts.SetRange(0, int64(len(buf3)))
- reader, objectInfo, err = c.GetObject(bucketName, objectName, opts)
- if err != nil {
- t.Fatal(err)
- }
-
- m, err = io.ReadFull(reader, buf3)
- if err != nil {
- reader.Close()
- t.Fatal(err)
- }
- reader.Close()
-
- if objectInfo.Size != int64(m) {
- t.Fatalf("Error: GetObject read shorter bytes before reaching EOF, want %v, got %v\n", objectInfo.Size, m)
- }
- if !bytes.Equal(buf3, buf) {
- t.Fatal("Error: Incorrect data read in GetObject, than what was previously upoaded.")
- }
-
- opts = GetObjectOptions{}
- opts.SetMatchETag("etag")
- _, _, err = c.GetObject(bucketName, objectName, opts)
- if err == nil {
- t.Fatal("Unexpected GetObject should fail with mismatching etags")
- }
- if errResp := ToErrorResponse(err); errResp.Code != "PreconditionFailed" {
- t.Fatalf("Expected \"PreconditionFailed\" as code, got %s instead", errResp.Code)
- }
-
- opts = GetObjectOptions{}
- opts.SetMatchETagExcept("etag")
- reader, objectInfo, err = c.GetObject(bucketName, objectName, opts)
- if err != nil {
- t.Fatal(err)
- }
-
- m, err = io.ReadFull(reader, buf3)
- reader.Close()
- if err != nil {
- t.Fatal(err)
- }
-
- if objectInfo.Size != int64(m) {
- t.Fatalf("Error: GetObject read shorter bytes before reaching EOF, want %v, got %v\n", objectInfo.Size, m)
- }
- if !bytes.Equal(buf3, buf) {
- t.Fatal("Error: Incorrect data read in GetObject, than what was previously upoaded.")
- }
-
- opts = GetObjectOptions{}
- opts.SetRange(0, 0)
- reader, objectInfo, err = c.GetObject(bucketName, objectName, opts)
- if err != nil {
- t.Fatal(err)
- }
-
- m, err = io.ReadFull(reader, buf4)
- reader.Close()
- if err != nil {
- t.Fatal(err)
- }
-
- if objectInfo.Size != int64(m) {
- t.Fatalf("Error: GetObject read shorter bytes before reaching EOF, want %v, got %v\n", objectInfo.Size, m)
- }
-
- err = c.RemoveObject(bucketName, objectName)
- if err != nil {
- t.Fatal("Error: ", err)
- }
- err = c.RemoveBucket(bucketName)
- if err != nil {
- t.Fatal("Error:", err)
- }
-}
-
-// Tests GetObject to return Content-Encoding properly set
-// and overrides any auto decoding.
-func TestGetObjectContentEncoding(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for the short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio core client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable tracing, write to stderr.
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- // Generate data more than 32K
- buf := bytes.Repeat([]byte("3"), rand.Intn(1<<20)+32*1024)
-
- // Save the data
- objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
- n, err := c.Client.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), PutObjectOptions{
- ContentEncoding: "gzip",
- })
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if n != int64(len(buf)) {
- t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), n)
- }
-
- rwc, objInfo, err := c.GetObject(bucketName, objectName, GetObjectOptions{})
- if err != nil {
- t.Fatalf("Error: %v", err)
- }
- rwc.Close()
- if objInfo.Size <= 0 {
- t.Fatalf("Unexpected size of the object %v, expected %v", objInfo.Size, n)
- }
- value, ok := objInfo.Metadata["Content-Encoding"]
- if !ok {
- t.Fatalf("Expected Content-Encoding metadata to be set.")
- }
- if value[0] != "gzip" {
- t.Fatalf("Unexpected content-encoding found, want gzip, got %v", value)
- }
-}
-
-// Tests get bucket policy core API.
-func TestGetBucketPolicy(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable to debug
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- // Verify if bucket exits and you have access.
- var exists bool
- exists, err = c.BucketExists(bucketName)
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
- if !exists {
- t.Fatal("Error: could not find ", bucketName)
- }
-
- // Asserting the default bucket policy.
- bucketPolicy, err := c.GetBucketPolicy(bucketName)
- if err != nil {
- errResp := ToErrorResponse(err)
- if errResp.Code != "NoSuchBucketPolicy" {
- t.Error("Error:", err, bucketName)
- }
- }
- if !reflect.DeepEqual(bucketPolicy, emptyBucketAccessPolicy) {
- t.Errorf("Bucket policy expected %#v, got %#v", emptyBucketAccessPolicy, bucketPolicy)
- }
-
- err = c.RemoveBucket(bucketName)
- if err != nil {
- t.Fatal("Error:", err)
- }
-}
-
-// Tests Core CopyObject API implementation.
-func TestCoreCopyObject(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable tracing, write to stderr.
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- buf := bytes.Repeat([]byte("a"), 32*1024)
-
- // Save the data
- objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
- objInfo, err := c.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), "", "", map[string]string{
- "Content-Type": "binary/octet-stream",
- })
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if objInfo.Size != int64(len(buf)) {
- t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), objInfo.Size)
- }
-
- destBucketName := bucketName
- destObjectName := objectName + "-dest"
-
- cobjInfo, err := c.CopyObject(bucketName, objectName, destBucketName, destObjectName, map[string]string{
- "X-Amz-Metadata-Directive": "REPLACE",
- "Content-Type": "application/javascript",
- })
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName, destBucketName, destObjectName)
- }
- if cobjInfo.ETag != objInfo.ETag {
- t.Fatalf("Error: expected etag to be same as source object %s, but found different etag :%s", objInfo.ETag, cobjInfo.ETag)
- }
-
- // Attempt to read from destBucketName and object name.
- r, err := c.Client.GetObject(destBucketName, destObjectName, GetObjectOptions{})
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- st, err := r.Stat()
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if st.Size != int64(len(buf)) {
- t.Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n",
- len(buf), st.Size)
- }
-
- if st.ContentType != "application/javascript" {
- t.Fatalf("Error: Content types don't match, expected: application/javascript, found: %+v\n", st.ContentType)
- }
-
- if st.ETag != objInfo.ETag {
- t.Fatalf("Error: expected etag to be same as source object %s, but found different etag :%s", objInfo.ETag, st.ETag)
- }
-
- if err := r.Close(); err != nil {
- t.Fatal("Error:", err)
- }
-
- if err := r.Close(); err == nil {
- t.Fatal("Error: object is already closed, should return error")
- }
-
- err = c.RemoveObject(bucketName, objectName)
- if err != nil {
- t.Fatal("Error: ", err)
- }
-
- err = c.RemoveObject(destBucketName, destObjectName)
- if err != nil {
- t.Fatal("Error: ", err)
- }
-
- err = c.RemoveBucket(bucketName)
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Do not need to remove destBucketName its same as bucketName.
-}
-
-// Test Core CopyObjectPart implementation
-func TestCoreCopyObjectPart(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable tracing, write to stderr.
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- // Make a buffer with 5MB of data
- buf := bytes.Repeat([]byte("abcde"), 1024*1024)
-
- // Save the data
- objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
- objInfo, err := c.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), "", "", map[string]string{
- "Content-Type": "binary/octet-stream",
- })
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if objInfo.Size != int64(len(buf)) {
- t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), objInfo.Size)
- }
-
- destBucketName := bucketName
- destObjectName := objectName + "-dest"
-
- uploadID, err := c.NewMultipartUpload(destBucketName, destObjectName, PutObjectOptions{})
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- // Content of the destination object will be two copies of
- // `objectName` concatenated, followed by first byte of
- // `objectName`.
-
- // First of three parts
- fstPart, err := c.CopyObjectPart(bucketName, objectName, destBucketName, destObjectName, uploadID, 1, 0, -1, nil)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
-
- // Second of three parts
- sndPart, err := c.CopyObjectPart(bucketName, objectName, destBucketName, destObjectName, uploadID, 2, 0, -1, nil)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
-
- // Last of three parts
- lstPart, err := c.CopyObjectPart(bucketName, objectName, destBucketName, destObjectName, uploadID, 3, 0, 1, nil)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
-
- // Complete the multipart upload
- err = c.CompleteMultipartUpload(destBucketName, destObjectName, uploadID, []CompletePart{fstPart, sndPart, lstPart})
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
-
- // Stat the object and check its length matches
- objInfo, err = c.StatObject(destBucketName, destObjectName, StatObjectOptions{})
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
-
- if objInfo.Size != (5*1024*1024)*2+1 {
- t.Fatal("Destination object has incorrect size!")
- }
-
- // Now we read the data back
- getOpts := GetObjectOptions{}
- getOpts.SetRange(0, 5*1024*1024-1)
- r, _, err := c.GetObject(destBucketName, destObjectName, getOpts)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
- getBuf := make([]byte, 5*1024*1024)
- _, err = io.ReadFull(r, getBuf)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
- if !bytes.Equal(getBuf, buf) {
- t.Fatal("Got unexpected data in first 5MB")
- }
-
- getOpts.SetRange(5*1024*1024, 0)
- r, _, err = c.GetObject(destBucketName, destObjectName, getOpts)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
- getBuf = make([]byte, 5*1024*1024+1)
- _, err = io.ReadFull(r, getBuf)
- if err != nil {
- t.Fatal("Error:", err, destBucketName, destObjectName)
- }
- if !bytes.Equal(getBuf[:5*1024*1024], buf) {
- t.Fatal("Got unexpected data in second 5MB")
- }
- if getBuf[5*1024*1024] != buf[0] {
- t.Fatal("Got unexpected data in last byte of copied object!")
- }
-
- if err := c.RemoveObject(destBucketName, destObjectName); err != nil {
- t.Fatal("Error: ", err)
- }
-
- if err := c.RemoveObject(bucketName, objectName); err != nil {
- t.Fatal("Error: ", err)
- }
-
- if err := c.RemoveBucket(bucketName); err != nil {
- t.Fatal("Error: ", err)
- }
-
- // Do not need to remove destBucketName its same as bucketName.
-}
-
-// Test Core PutObject.
-func TestCorePutObject(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for short runs")
- }
-
- // Seed random based on current time.
- rand.Seed(time.Now().Unix())
-
- // Instantiate new minio client object.
- c, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)),
- )
- if err != nil {
- t.Fatal("Error:", err)
- }
-
- // Enable tracing, write to stderr.
- // c.TraceOn(os.Stderr)
-
- // Set user agent.
- c.SetAppInfo("Minio-go-FunctionalTest", "0.1.0")
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = c.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- buf := bytes.Repeat([]byte("a"), 32*1024)
-
- // Save the data
- objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
- // Object content type
- objectContentType := "binary/octet-stream"
- metadata := make(map[string]string)
- metadata["Content-Type"] = objectContentType
-
- objInfo, err := c.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), "1B2M2Y8AsgTpgAmY7PhCfg==", "", metadata)
- if err == nil {
- t.Fatal("Error expected: error, got: nil(success)")
- }
-
- objInfo, err = c.PutObject(bucketName, objectName, bytes.NewReader(buf), int64(len(buf)), "", "", metadata)
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if objInfo.Size != int64(len(buf)) {
- t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), objInfo.Size)
- }
-
- // Read the data back
- r, err := c.Client.GetObject(bucketName, objectName, GetObjectOptions{})
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- st, err := r.Stat()
- if err != nil {
- t.Fatal("Error:", err, bucketName, objectName)
- }
-
- if st.Size != int64(len(buf)) {
- t.Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n",
- len(buf), st.Size)
- }
-
- if st.ContentType != objectContentType {
- t.Fatalf("Error: Content types don't match, expected: %+v, found: %+v\n", objectContentType, st.ContentType)
- }
-
- if err := r.Close(); err != nil {
- t.Fatal("Error:", err)
- }
-
- if err := r.Close(); err == nil {
- t.Fatal("Error: object is already closed, should return error")
- }
-
- err = c.RemoveObject(bucketName, objectName)
- if err != nil {
- t.Fatal("Error: ", err)
- }
-
- err = c.RemoveBucket(bucketName)
- if err != nil {
- t.Fatal("Error:", err)
- }
-}
-
-func TestCoreGetObjectMetadata(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping functional tests for the short runs")
- }
-
- core, err := NewCore(
- os.Getenv(serverEndpoint),
- os.Getenv(accessKey),
- os.Getenv(secretKey),
- mustParseBool(os.Getenv(enableSecurity)))
- if err != nil {
- log.Fatalln(err)
- }
-
- // Generate a new random bucket name.
- bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test")
-
- // Make a new bucket.
- err = core.MakeBucket(bucketName, "us-east-1")
- if err != nil {
- t.Fatal("Error:", err, bucketName)
- }
-
- metadata := map[string]string{
- "X-Amz-Meta-Key-1": "Val-1",
- }
-
- _, err = core.PutObject(bucketName, "my-objectname",
- bytes.NewReader([]byte("hello")), 5, "", "", metadata)
- if err != nil {
- log.Fatalln(err)
- }
-
- reader, objInfo, err := core.GetObject(bucketName, "my-objectname", GetObjectOptions{})
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- if objInfo.Metadata.Get("X-Amz-Meta-Key-1") != "Val-1" {
- log.Fatalln("Expected metadata to be available but wasn't")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/docs/API.md b/vendor/github.com/minio/minio-go/docs/API.md
deleted file mode 100644
index cc59375f6..000000000
--- a/vendor/github.com/minio/minio-go/docs/API.md
+++ /dev/null
@@ -1,1831 +0,0 @@
-# Minio Go Client API Reference [![Slack](https://slack.minio.io/slack?type=svg)](https://slack.minio.io)
-
-## Initialize Minio Client object.
-
-## Minio
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Use a secure connection.
- ssl := true
-
- // Initialize minio client object.
- minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
- if err != nil {
- fmt.Println(err)
- return
- }
-}
-```
-
-## AWS S3
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Use a secure connection.
- ssl := true
-
- // Initialize minio client object.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ssl)
- if err != nil {
- fmt.Println(err)
- return
- }
-}
-```
-
-| Bucket operations | Object operations | Encrypted Object operations | Presigned operations | Bucket Policy/Notification Operations | Client custom settings |
-| :--- | :--- | :--- | :--- | :--- | :--- |
-| [`MakeBucket`](#MakeBucket) | [`GetObject`](#GetObject) | [`NewSymmetricKey`](#NewSymmetricKey) | [`PresignedGetObject`](#PresignedGetObject) | [`SetBucketPolicy`](#SetBucketPolicy) | [`SetAppInfo`](#SetAppInfo) |
-| [`ListBuckets`](#ListBuckets) | [`PutObject`](#PutObject) | [`NewAsymmetricKey`](#NewAsymmetricKey) | [`PresignedPutObject`](#PresignedPutObject) | [`GetBucketPolicy`](#GetBucketPolicy) | [`SetCustomTransport`](#SetCustomTransport) |
-| [`BucketExists`](#BucketExists) | [`CopyObject`](#CopyObject) | [`GetEncryptedObject`](#GetEncryptedObject) | [`PresignedPostPolicy`](#PresignedPostPolicy) | [`ListBucketPolicies`](#ListBucketPolicies) | [`TraceOn`](#TraceOn) |
-| [`RemoveBucket`](#RemoveBucket) | [`StatObject`](#StatObject) | [`PutEncryptedObject`](#PutEncryptedObject) | | [`SetBucketNotification`](#SetBucketNotification) | [`TraceOff`](#TraceOff) |
-| [`ListObjects`](#ListObjects) | [`RemoveObject`](#RemoveObject) | [`NewSSEInfo`](#NewSSEInfo) | | [`GetBucketNotification`](#GetBucketNotification) | [`SetS3TransferAccelerate`](#SetS3TransferAccelerate) |
-| [`ListObjectsV2`](#ListObjectsV2) | [`RemoveObjects`](#RemoveObjects) | [`FPutEncryptedObject`](#FPutEncryptedObject) | | [`RemoveAllBucketNotification`](#RemoveAllBucketNotification) | |
-| [`ListIncompleteUploads`](#ListIncompleteUploads) | [`RemoveIncompleteUpload`](#RemoveIncompleteUpload) | | | [`ListenBucketNotification`](#ListenBucketNotification) | |
-| | [`FPutObject`](#FPutObject) | | | | |
-| | [`FGetObject`](#FGetObject) | | | | |
-| | [`ComposeObject`](#ComposeObject) | | | | |
-| | [`NewSourceInfo`](#NewSourceInfo) | | | | |
-| | [`NewDestinationInfo`](#NewDestinationInfo) | | | | |
-| | [`PutObjectWithContext`](#PutObjectWithContext) | | | |
-| | [`GetObjectWithContext`](#GetObjectWithContext) | | | |
-| | [`FPutObjectWithContext`](#FPutObjectWithContext) | | | |
-| | [`FGetObjectWithContext`](#FGetObjectWithContext) | | | |
-## 1. Constructor
-<a name="Minio"></a>
-
-### New(endpoint, accessKeyID, secretAccessKey string, ssl bool) (*Client, error)
-Initializes a new client object.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`endpoint` | _string_ |S3 compatible object storage endpoint |
-|`accessKeyID` |_string_ |Access key for the object storage |
-|`secretAccessKey` | _string_ |Secret key for the object storage |
-|`ssl` | _bool_ | If 'true' API requests will be secure (HTTPS), and insecure (HTTP) otherwise |
-
-### NewWithRegion(endpoint, accessKeyID, secretAccessKey string, ssl bool, region string) (*Client, error)
-Initializes minio client, with region configured. Unlike New(), NewWithRegion avoids bucket-location lookup operations and it is slightly faster. Use this function when your application deals with a single region.
-
-### NewWithOptions(endpoint string, options *Options) (*Client, error)
-Initializes minio client with options configured.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`endpoint` | _string_ |S3 compatible object storage endpoint |
-|`opts` |_minio.Options_ | Options for constructing a new client|
-
-__minio.Options__
-
-|Field | Type | Description |
-|:--- |:--- | :--- |
-| `opts.Creds` | _*credentials.Credentials_ | Access Credentials|
-| `opts.Secure` | _bool_ | If 'true' API requests will be secure (HTTPS), and insecure (HTTP) otherwise |
-| `opts.Region` | _string_ | region |
-| `opts.BucketLookup` | _BucketLookupType_ | Bucket lookup type can be one of the following values |
-| | | _minio.BucketLookupDNS_ |
-| | | _minio.BucketLookupPath_ |
-| | | _minio.BucketLookupAuto_ |
-## 2. Bucket operations
-
-<a name="MakeBucket"></a>
-### MakeBucket(bucketName, location string) error
-Creates a new bucket.
-
-__Parameters__
-
-| Param | Type | Description |
-|---|---|---|
-|`bucketName` | _string_ | Name of the bucket |
-| `location` | _string_ | Region where the bucket is to be created. Default value is us-east-1. Other valid values are listed below. Note: When used with minio server, use the region specified in its config file (defaults to us-east-1).|
-| | |us-east-1 |
-| | |us-west-1 |
-| | |us-west-2 |
-| | |eu-west-1 |
-| | | eu-central-1|
-| | | ap-southeast-1|
-| | | ap-northeast-1|
-| | | ap-southeast-2|
-| | | sa-east-1|
-
-
-__Example__
-
-
-```go
-err = minioClient.MakeBucket("mybucket", "us-east-1")
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully created mybucket.")
-```
-
-<a name="ListBuckets"></a>
-### ListBuckets() ([]BucketInfo, error)
-Lists all buckets.
-
-| Param | Type | Description |
-|---|---|---|
-|`bucketList` | _[]minio.BucketInfo_ | Lists of all buckets |
-
-
-__minio.BucketInfo__
-
-| Field | Type | Description |
-|---|---|---|
-|`bucket.Name` | _string_ | Name of the bucket |
-|`bucket.CreationDate` | _time.Time_ | Date of bucket creation |
-
-
-__Example__
-
-
-```go
-buckets, err := minioClient.ListBuckets()
-if err != nil {
- fmt.Println(err)
- return
-}
-for _, bucket := range buckets {
- fmt.Println(bucket)
-}
-```
-
-<a name="BucketExists"></a>
-### BucketExists(bucketName string) (found bool, err error)
-Checks if a bucket exists.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-
-
-__Return Values__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`found` | _bool_ | Indicates whether bucket exists or not |
-|`err` | _error_ | Standard Error |
-
-
-__Example__
-
-
-```go
-found, err := minioClient.BucketExists("mybucket")
-if err != nil {
- fmt.Println(err)
- return
-}
-if found {
- fmt.Println("Bucket found")
-}
-```
-
-<a name="RemoveBucket"></a>
-### RemoveBucket(bucketName string) error
-Removes a bucket, bucket should be empty to be successfully removed.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-
-__Example__
-
-
-```go
-err = minioClient.RemoveBucket("mybucket")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="ListObjects"></a>
-### ListObjects(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
-Lists objects in a bucket.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectPrefix` |_string_ | Prefix of objects to be listed |
-|`recursive` | _bool_ |`true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. |
-|`doneCh` | _chan struct{}_ | A message on this channel ends the ListObjects iterator. |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`objectInfo` | _chan minio.ObjectInfo_ |Read channel for all objects in the bucket, the object is of the format listed below: |
-
-__minio.ObjectInfo__
-
-|Field |Type |Description |
-|:---|:---| :---|
-|`objectInfo.Key` | _string_ |Name of the object |
-|`objectInfo.Size` | _int64_ |Size of the object |
-|`objectInfo.ETag` | _string_ |MD5 checksum of the object |
-|`objectInfo.LastModified` | _time.Time_ |Time when object was last modified |
-
-
-```go
-// Create a done channel to control 'ListObjects' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true
-objectCh := minioClient.ListObjects("mybucket", "myprefix", isRecursive, doneCh)
-for object := range objectCh {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
-}
-```
-
-
-<a name="ListObjectsV2"></a>
-### ListObjectsV2(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
-Lists objects in a bucket using the recommended listing API v2
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-| `objectPrefix` |_string_ | Prefix of objects to be listed |
-| `recursive` | _bool_ |`true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. |
-|`doneCh` | _chan struct{}_ | A message on this channel ends the ListObjectsV2 iterator. |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`objectInfo` | _chan minio.ObjectInfo_ |Read channel for all the objects in the bucket, the object is of the format listed below: |
-
-
-```go
-// Create a done channel to control 'ListObjectsV2' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true
-objectCh := minioClient.ListObjectsV2("mybucket", "myprefix", isRecursive, doneCh)
-for object := range objectCh {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
-}
-```
-
-<a name="ListIncompleteUploads"></a>
-### ListIncompleteUploads(bucketName, prefix string, recursive bool, doneCh chan struct{}) <- chan ObjectMultipartInfo
-Lists partially uploaded objects in a bucket.
-
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-| `prefix` |_string_ | Prefix of objects that are partially uploaded |
-| `recursive` | _bool_ |`true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. |
-|`doneCh` | _chan struct{}_ | A message on this channel ends the ListenIncompleteUploads iterator. |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`multiPartInfo` | _chan minio.ObjectMultipartInfo_ |Emits multipart objects of the format listed below: |
-
-__minio.ObjectMultipartInfo__
-
-|Field |Type |Description |
-|:---|:---| :---|
-|`multiPartObjInfo.Key` | _string_ |Name of incompletely uploaded object |
-|`multiPartObjInfo.UploadID` | _string_ |Upload ID of incompletely uploaded object |
-|`multiPartObjInfo.Size` | _int64_ |Size of incompletely uploaded object |
-
-__Example__
-
-
-```go
-// Create a done channel to control 'ListObjects' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true // Recursively list everything at 'myprefix'
-multiPartObjectCh := minioClient.ListIncompleteUploads("mybucket", "myprefix", isRecursive, doneCh)
-for multiPartObject := range multiPartObjectCh {
- if multiPartObject.Err != nil {
- fmt.Println(multiPartObject.Err)
- return
- }
- fmt.Println(multiPartObject)
-}
-```
-
-## 3. Object operations
-
-<a name="GetObject"></a>
-### GetObject(bucketName, objectName string, opts GetObjectOptions) (*Object, error)
-Returns a stream of the object data. Most of the common errors occur when reading the stream.
-
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`opts` | _minio.GetObjectOptions_ | Options for GET requests specifying additional options like encryption, If-Match |
-
-
-__minio.GetObjectOptions__
-
-|Field | Type | Description |
-|:---|:---|:---|
-| `opts.Materials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go) |
-
-__Return Value__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`object` | _*minio.Object_ |_minio.Object_ represents object reader. It implements io.Reader, io.Seeker, io.ReaderAt and io.Closer interfaces. |
-
-
-__Example__
-
-
-```go
-object, err := minioClient.GetObject("mybucket", "myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetObject"></a>
-### FGetObject(bucketName, objectName, filePath string, opts GetObjectOptions) error
-Downloads and saves the object as a file in the local filesystem.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to download object to |
-|`opts` | _minio.GetObjectOptions_ | Options for GET requests specifying additional options like encryption, If-Match |
-
-
-__Example__
-
-
-```go
-err = minioClient.FGetObject("mybucket", "myobject", "/tmp/myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-<a name="GetObjectWithContext"></a>
-### GetObjectWithContext(ctx context.Context, bucketName, objectName string, opts GetObjectOptions) (*Object, error)
-Identical to GetObject operation, but accepts a context for request cancellation.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |Request context |
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`opts` | _minio.GetObjectOptions_ | Options for GET requests specifying additional options like encryption, If-Match |
-
-
-__Return Value__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`object` | _*minio.Object_ |_minio.Object_ represents object reader. It implements io.Reader, io.Seeker, io.ReaderAt and io.Closer interfaces. |
-
-
-__Example__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-object, err := minioClient.GetObjectWithContext(ctx, "mybucket", "myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetObjectWithContext"></a>
-### FGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error
-Identical to FGetObject operation, but allows request cancellation.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |Request context |
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to download object to |
-|`opts` | _minio.GetObjectOptions_ | Options for GET requests specifying additional options like encryption, If-Match |
-
-
-__Example__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-err = minioClient.FGetObjectWithContext(ctx, "mybucket", "myobject", "/tmp/myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetEncryptedObject"></a>
-### FGetEncryptedObject(bucketName, objectName, filePath string, materials encrypt.Materials) error
-Identical to FGetObject operation, but decrypts an encrypted request
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to download object to |
-|`materials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go) |
-
-
-__Example__
-
-
-```go
-// Generate a master symmetric key
-key := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-err = minioClient.FGetEncryptedObject("mybucket", "myobject", "/tmp/myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="PutObject"></a>
-### PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,opts PutObjectOptions) (n int, err error)
-Uploads objects that are less than 64MiB in a single PUT operation. For objects that are greater than 64MiB in size, PutObject seamlessly uploads the object as parts of 64MiB or more depending on the actual file size. The max upload size for an object is 5TB.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`reader` | _io.Reader_ |Any Go type that implements io.Reader |
-|`objectSize`| _int64_ |Size of the object being uploaded. Pass -1 if stream size is unknown |
-|`opts` | _minio.PutObjectOptions_ | Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation. |
-
-__minio.PutObjectOptions__
-
-|Field | Type | Description |
-|:--- |:--- | :--- |
-| `opts.UserMetadata` | _map[string]string_ | Map of user metadata|
-| `opts.Progress` | _io.Reader_ | Reader to fetch progress of an upload |
-| `opts.ContentType` | _string_ | Content type of object, e.g "application/text" |
-| `opts.ContentEncoding` | _string_ | Content encoding of object, e.g "gzip" |
-| `opts.ContentDisposition` | _string_ | Content disposition of object, "inline" |
-| `opts.CacheControl` | _string_ | Used to specify directives for caching mechanisms in both requests and responses e.g "max-age=600"|
-| `opts.EncryptMaterials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go) |
-| `opts.StorageClass` | _string_ | Specify storage class for the object. Supported values for Minio server are `REDUCED_REDUNDANCY` and `STANDARD` |
-
-__Example__
-
-
-```go
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-fileStat, err := file.Stat()
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.PutObject("mybucket", "myobject", file, fileStat.Size(), minio.PutObjectOptions{ContentType:"application/octet-stream"})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-API methods PutObjectWithSize, PutObjectWithMetadata, PutObjectStreaming, and PutObjectWithProgress available in minio-go SDK release v3.0.3 are replaced by the new PutObject call variant that accepts a pointer to PutObjectOptions struct.
-
-<a name="PutObjectWithContext"></a>
-### PutObjectWithContext(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts PutObjectOptions) (n int, err error)
-Identical to PutObject operation, but allows request cancellation.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |Request context |
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`reader` | _io.Reader_ |Any Go type that implements io.Reader |
-|`objectSize`| _int64_ | size of the object being uploaded. Pass -1 if stream size is unknown |
-|`opts` | _minio.PutObjectOptions_ |Pointer to struct that allows user to set optional custom metadata, content-type, content-encoding,content-disposition and cache-control headers, pass encryption module for encrypting objects, and optionally configure number of threads for multipart put operation. |
-
-
-__Example__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 10 * time.Second)
-defer cancel()
-
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-fileStat, err := file.Stat()
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.PutObjectWithContext(ctx, "my-bucketname", "my-objectname", file, fileStat.Size(), minio.PutObjectOptions{
- ContentType: "application/octet-stream",
-})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="CopyObject"></a>
-### CopyObject(dst DestinationInfo, src SourceInfo) error
-Create or replace an object through server-side copying of an existing object. It supports conditional copying, copying a part of an object and server-side encryption of destination and decryption of source. See the `SourceInfo` and `DestinationInfo` types for further details.
-
-To copy multiple source objects into a single destination object see the `ComposeObject` API.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`dst` | _minio.DestinationInfo_ |Argument describing the destination object |
-|`src` | _minio.SourceInfo_ |Argument describing the source object |
-
-
-__Example__
-
-
-```go
-// Use-case 1: Simple copy object with no conditions.
-// Source object
-src := minio.NewSourceInfo("my-sourcebucketname", "my-sourceobjectname", nil)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-// Use-case 2:
-// Copy object with copy-conditions, and copying only part of the source object.
-// 1. that matches a given ETag
-// 2. and modified after 1st April 2014
-// 3. but unmodified since 23rd April 2014
-// 4. copy only first 1MiB of object.
-
-// Source object
-src := minio.NewSourceInfo("my-sourcebucketname", "my-sourceobjectname", nil)
-
-// Set matching ETag condition, copy object which matches the following ETag.
-src.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
-// Set modified condition, copy object modified since 2014 April 1.
-src.SetModifiedSinceCond(time.Date(2014, time.April, 1, 0, 0, 0, 0, time.UTC))
-
-// Set unmodified condition, copy object unmodified since 2014 April 23.
-src.SetUnmodifiedSinceCond(time.Date(2014, time.April, 23, 0, 0, 0, 0, time.UTC))
-
-// Set copy-range of only first 1MiB of file.
-src.SetRange(0, 1024*1024-1)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="ComposeObject"></a>
-### ComposeObject(dst minio.DestinationInfo, srcs []minio.SourceInfo) error
-Create an object by concatenating a list of source objects using server-side copying.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---|:---|
-|`dst` | _minio.DestinationInfo_ |Struct with info about the object to be created. |
-|`srcs` | _[]minio.SourceInfo_ |Slice of struct with info about source objects to be concatenated in order. |
-
-
-__Example__
-
-
-```go
-// Prepare source decryption key (here we assume same key to
-// decrypt all source objects.)
-decKey := minio.NewSSEInfo([]byte{1, 2, 3}, "")
-
-// Source objects to concatenate. We also specify decryption
-// key for each
-src1 := minio.NewSourceInfo("bucket1", "object1", &decKey)
-src1.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
-src2 := minio.NewSourceInfo("bucket2", "object2", &decKey)
-src2.SetMatchETagCond("f8ef9c385918b653a31624deb84149d2")
-
-src3 := minio.NewSourceInfo("bucket3", "object3", &decKey)
-src3.SetMatchETagCond("5918b653a31624deb84149d2f8ef9c38")
-
-// Create slice of sources.
-srcs := []minio.SourceInfo{src1, src2, src3}
-
-// Prepare destination encryption key
-encKey := minio.NewSSEInfo([]byte{8, 9, 0}, "")
-
-// Create destination info
-dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Compose object call by concatenating multiple source files.
-err = minioClient.ComposeObject(dst, srcs)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-fmt.Println("Composed object successfully.")
-```
-
-<a name="NewSourceInfo"></a>
-### NewSourceInfo(bucket, object string, decryptSSEC *SSEInfo) SourceInfo
-Construct a `SourceInfo` object that can be used as the source for server-side copying operations like `CopyObject` and `ComposeObject`. This object can be used to set copy-conditions on the source.
-
-__Parameters__
-
-| Param | Type | Description |
-| :--- | :--- | :--- |
-| `bucket` | _string_ | Name of the source bucket |
-| `object` | _string_ | Name of the source object |
-| `decryptSSEC` | _*minio.SSEInfo_ | Decryption info for the source object (`nil` without encryption) |
-
-__Example__
-
-```go
-// No decryption parameter.
-src := minio.NewSourceInfo("bucket", "object", nil)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-// With decryption parameter.
-decKey := minio.NewSSEInfo([]byte{1,2,3}, "")
-src := minio.NewSourceInfo("bucket", "object", &decKey)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="NewDestinationInfo"></a>
-### NewDestinationInfo(bucket, object string, encryptSSEC *SSEInfo, userMeta map[string]string) (DestinationInfo, error)
-Construct a `DestinationInfo` object that can be used as the destination object for server-side copying operations like `CopyObject` and `ComposeObject`.
-
-__Parameters__
-
-| Param | Type | Description |
-| :--- | :--- | :--- |
-| `bucket` | _string_ | Name of the destination bucket |
-| `object` | _string_ | Name of the destination object |
-| `encryptSSEC` | _*minio.SSEInfo_ | Encryption info for the source object (`nil` without encryption) |
-| `userMeta` | _map[string]string_ | User metadata to be set on the destination. If nil, with only one source, user-metadata is copied from source. |
-
-__Example__
-
-```go
-// No encryption parameter.
-src := minio.NewSourceInfo("bucket", "object", nil)
-dst, err := minio.NewDestinationInfo("bucket", "object", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-src := minio.NewSourceInfo("bucket", "object", nil)
-
-// With encryption parameter.
-encKey := minio.NewSSEInfo([]byte{1,2,3}, "")
-dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FPutObject"></a>
-### FPutObject(bucketName, objectName, filePath, opts PutObjectOptions) (length int64, err error)
-Uploads contents from a file to objectName.
-
-FPutObject uploads objects that are less than 64MiB in a single PUT operation. For objects that are greater than the 64MiB in size, FPutObject seamlessly uploads the object in chunks of 64MiB or more depending on the actual file size. The max upload size for an object is 5TB.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to file to be uploaded |
-|`opts` | _minio.PutObjectOptions_ |Pointer to struct that allows user to set optional custom metadata, content-type, content-encoding,content-disposition and cache-control headers, pass encryption module for encrypting objects, and optionally configure number of threads for multipart put operation. |
-
-
-__Example__
-
-
-```go
-n, err := minioClient.FPutObject("my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{
- ContentType: "application/csv",
-});
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="FPutObjectWithContext"></a>
-### FPutObjectWithContext(ctx context.Context, bucketName, objectName, filePath, opts PutObjectOptions) (length int64, err error)
-Identical to FPutObject operation, but allows request cancellation.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |Request context |
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to file to be uploaded |
-|`opts` | _minio.PutObjectOptions_ |Pointer to struct that allows user to set optional custom metadata, content-type, content-encoding,content-disposition and cache-control headers, pass encryption module for encrypting objects, and optionally configure number of threads for multipart put operation. |
-
-__Example__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-n, err := minioClient.FPutObjectWithContext(ctx, "mybucket", "myobject.csv", "/tmp/otherobject.csv", minio.PutObjectOptions{ContentType:"application/csv"})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="StatObject"></a>
-### StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error)
-Fetch metadata of an object.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`opts` | _minio.StatObjectOptions_ | Options for GET info/stat requests specifying additional options like encryption, If-Match |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`objInfo` | _minio.ObjectInfo_ |Object stat information |
-
-
-__minio.ObjectInfo__
-
-|Field |Type |Description |
-|:---|:---| :---|
-|`objInfo.LastModified` | _time.Time_ |Time when object was last modified |
-|`objInfo.ETag` | _string_ |MD5 checksum of the object|
-|`objInfo.ContentType` | _string_ |Content type of the object|
-|`objInfo.Size` | _int64_ |Size of the object|
-
-
-__Example__
-
-
-```go
-objInfo, err := minioClient.StatObject("mybucket", "myobject", minio.StatObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println(objInfo)
-```
-
-<a name="RemoveObject"></a>
-### RemoveObject(bucketName, objectName string) error
-Removes an object.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-
-
-```go
-err = minioClient.RemoveObject("mybucket", "myobject")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="RemoveObjects"></a>
-### RemoveObjects(bucketName string, objectsCh chan string) (errorCh <-chan RemoveObjectError)
-Removes a list of objects obtained from an input channel. The call sends a delete request to the server up to 1000 objects at a time. The errors observed are sent over the error channel.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectsCh` | _chan string_ | Channel of objects to be removed |
-
-
-__Return Values__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`errorCh` | _<-chan minio.RemoveObjectError_ | Receive-only channel of errors observed during deletion. |
-
-
-```go
-objectsCh := make(chan string)
-
-// Send object names that are needed to be removed to objectsCh
-go func() {
- defer close(objectsCh)
- // List all objects from a bucket-name with a matching prefix.
- for object := range minioClient.ListObjects("my-bucketname", "my-prefixname", true, nil) {
- if object.Err != nil {
- log.Fatalln(object.Err)
- }
- objectsCh <- object.Key
- }
-}()
-
-for rErr := range minioClient.RemoveObjects("mybucket", objectsCh) {
- fmt.Println("Error detected during deletion: ", rErr)
-}
-```
-
-<a name="RemoveIncompleteUpload"></a>
-### RemoveIncompleteUpload(bucketName, objectName string) error
-Removes a partially uploaded object.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-
-__Example__
-
-
-```go
-err = minioClient.RemoveIncompleteUpload("mybucket", "myobject")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-## 4. Encrypted object operations
-
-<a name="NewSymmetricKey"></a>
-### NewSymmetricKey(key []byte) *encrypt.SymmetricKey
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`key` | _string_ |Name of the bucket |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`symmetricKey` | _*encrypt.SymmetricKey_ | represents a symmetric key structure which can be used to encrypt and decrypt data |
-
-```go
-symKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material with symmetric key.
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(symKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully initialized Symmetric key CBC materials", cbcMaterials)
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-```
-
-<a name="NewAsymmetricKey"></a>
-### NewAsymmetricKey(privateKey []byte, publicKey[]byte) (*encrypt.AsymmetricKey, error)
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`privateKey` | _[]byte_ | Private key data |
-|`publicKey` | _[]byte_ | Public key data |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`asymmetricKey` | _*encrypt.AsymmetricKey_ | represents an asymmetric key structure which can be used to encrypt and decrypt data |
-|`err` | _error_ | Standard Error |
-
-
-```go
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Initialize the asymmetric key
-asymmetricKey, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption material for asymmetric key.
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(asymmetricKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully initialized Asymmetric key CBC materials", cbcMaterials)
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-```
-
-<a name="GetEncryptedObject"></a>
-### GetEncryptedObject(bucketName, objectName string, encryptMaterials encrypt.Materials) (io.ReadCloser, error)
-
-Returns the decrypted stream of the object data based of the given encryption materials. Most of the common errors occur when reading the stream.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ | Name of the bucket |
-|`objectName` | _string_ | Name of the object |
-|`encryptMaterials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go) |
-
-
-__Return Value__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`stream` | _io.ReadCloser_ | Returns the deciphered object reader, caller should close after reading. |
-|`err` | _error | Returns errors. |
-
-
-__Example__
-
-
-```go
-// Generate a master symmetric key
-key := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer localFile.Close()
-
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="PutEncryptedObject"></a>
-
-### PutEncryptedObject(bucketName, objectName string, reader io.Reader, encryptMaterials encrypt.Materials) (n int, err error)
-Encrypt and upload an object.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`reader` | _io.Reader_ |Any Go type that implements io.Reader |
-|`encryptMaterials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go) |
-
-__Example__
-
-```go
-// Load a private key
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Load a public key
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build an asymmetric key
-key, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption module
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Open a file to upload
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-// Upload the encrypted form of the file
-n, err := minioClient.PutEncryptedObject("mybucket", "myobject", file, cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded encrypted bytes: ", n)
-```
-
-<a name="FPutEncryptedObject"></a>
-### FPutEncryptedObject(bucketName, objectName, filePath, encryptMaterials encrypt.Materials) (n int, err error)
-Encrypt and upload an object from a file.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`filePath` | _string_ |Path to file to be uploaded |
-|`encryptMaterials` | _encrypt.Materials_ | Interface provided by `encrypt` package to encrypt a stream of data (For more information see https://godoc.org/github.com/minio/minio-go)The module that encrypts data |
-
-__Example__
-
-
-```go
-// Load a private key
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Load a public key
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build an asymmetric key
-key, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption module
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.FPutEncryptedObject("mybucket", "myobject.csv", "/tmp/otherobject.csv", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded encrypted bytes: ", n)
-```
-
-<a name="NewSSEInfo"></a>
-
-### NewSSEInfo(key []byte, algo string) SSEInfo
-Create a key object for use as encryption or decryption parameter in operations involving server-side-encryption with customer provided key (SSE-C).
-
-__Parameters__
-
-| Param | Type | Description |
-| :--- | :--- | :--- |
-| `key` | _[]byte_ | Byte-slice of the raw, un-encoded binary key |
-| `algo` | _string_ | Algorithm to use in encryption or decryption with the given key. Can be empty (defaults to `AES256`) |
-
-
-## 5. Presigned operations
-
-<a name="PresignedGetObject"></a>
-### PresignedGetObject(bucketName, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
-Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`expiry` | _time.Duration_ |Expiry of presigned URL in seconds |
-|`reqParams` | _url.Values_ |Additional response header overrides supports _response-expires_, _response-content-type_, _response-cache-control_, _response-content-disposition_. |
-
-
-__Example__
-
-
-```go
-// Set request parameters for content-disposition.
-reqParams := make(url.Values)
-reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
-// Generates a presigned url which expires in a day.
-presignedURL, err := minioClient.PresignedGetObject("mybucket", "myobject", time.Second * 24 * 60 * 60, reqParams)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedPutObject"></a>
-### PresignedPutObject(bucketName, objectName string, expiry time.Duration) (*url.URL, error)
-Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.
-
-NOTE: you can upload to S3 only with specified object name.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`expiry` | _time.Duration_ |Expiry of presigned URL in seconds |
-
-
-__Example__
-
-
-```go
-// Generates a url which expires in a day.
-expiry := time.Second * 24 * 60 * 60 // 1 day.
-presignedURL, err := minioClient.PresignedPutObject("mybucket", "myobject", expiry)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedHeadObject"></a>
-### PresignedHeadObject(bucketName, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
-Generates a presigned URL for HTTP HEAD operations. Browsers/Mobile clients may point to this URL to directly get metadata from objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.
-
-__Parameters__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectName` | _string_ |Name of the object |
-|`expiry` | _time.Duration_ |Expiry of presigned URL in seconds |
-|`reqParams` | _url.Values_ |Additional response header overrides supports _response-expires_, _response-content-type_, _response-cache-control_, _response-content-disposition_. |
-
-
-__Example__
-
-
-```go
-// Set request parameters for content-disposition.
-reqParams := make(url.Values)
-reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
-// Generates a presigned url which expires in a day.
-presignedURL, err := minioClient.PresignedHeadObject("mybucket", "myobject", time.Second * 24 * 60 * 60, reqParams)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedPostPolicy"></a>
-### PresignedPostPolicy(PostPolicy) (*url.URL, map[string]string, error)
-Allows setting policy conditions to a presigned URL for POST operations. Policies such as bucket name to receive object uploads, key name prefixes, expiry policy may be set.
-
-```go
-// Initialize policy condition config.
-policy := minio.NewPostPolicy()
-
-// Apply upload policy restrictions:
-policy.SetBucket("mybucket")
-policy.SetKey("myobject")
-policy.SetExpires(time.Now().UTC().AddDate(0, 0, 10)) // expires in 10 days
-
-// Only allow 'png' images.
-policy.SetContentType("image/png")
-
-// Only allow content size in range 1KB to 1MB.
-policy.SetContentLengthRange(1024, 1024*1024)
-
-// Add a user metadata using the key "custom" and value "user"
-policy.SetUserMetadata("custom", "user")
-
-// Get the POST form key/value object:
-url, formData, err := minioClient.PresignedPostPolicy(policy)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// POST your content from the command line using `curl`
-fmt.Printf("curl ")
-for k, v := range formData {
- fmt.Printf("-F %s=%s ", k, v)
-}
-fmt.Printf("-F file=@/etc/bash.bashrc ")
-fmt.Printf("%s\n", url)
-```
-
-## 6. Bucket policy/notification operations
-
-<a name="SetBucketPolicy"></a>
-### SetBucketPolicy(bucketname, objectPrefix string, policy policy.BucketPolicy) error
-Set access permissions on bucket or an object prefix.
-
-Importing `github.com/minio/minio-go/pkg/policy` package is needed.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket|
-|`objectPrefix` | _string_ |Name of the object prefix|
-|`policy` | _policy.BucketPolicy_ |Policy can be one of the following, |
-| | | _policy.BucketPolicyNone_ |
-| | | _policy.BucketPolicyReadOnly_ |
-| | | _policy.BucketPolicyReadWrite_ |
-| | | _policy.BucketPolicyWriteOnly_ |
-
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`err` | _error_ |Standard Error |
-
-
-__Example__
-
-
-```go
-// Sets 'mybucket' with a sub-directory 'myprefix' to be anonymously accessible for
-// both read and write operations.
-err = minioClient.SetBucketPolicy("mybucket", "myprefix", policy.BucketPolicyReadWrite)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="GetBucketPolicy"></a>
-### GetBucketPolicy(bucketName, objectPrefix string) (policy.BucketPolicy, error)
-Get access permissions on a bucket or a prefix.
-
-Importing `github.com/minio/minio-go/pkg/policy` package is needed.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectPrefix` | _string_ |Prefix matching objects under the bucket |
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketPolicy` | _policy.BucketPolicy_ |string that contains: `none`, `readonly`, `readwrite`, or `writeonly` |
-|`err` | _error_ |Standard Error |
-
-__Example__
-
-
-```go
-bucketPolicy, err := minioClient.GetBucketPolicy("mybucket", "")
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Access permissions for mybucket is", bucketPolicy)
-```
-
-<a name="ListBucketPolicies"></a>
-### ListBucketPolicies(bucketName, objectPrefix string) (map[string]BucketPolicy, error)
-Get access permissions rules associated to the specified bucket and prefix.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`objectPrefix` | _string_ |Prefix matching objects under the bucket |
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketPolicies` | _map[string]minio.BucketPolicy_ |Map of object resource paths and their permissions |
-|`err` | _error_ |Standard Error |
-
-__Example__
-
-
-```go
-bucketPolicies, err := minioClient.ListBucketPolicies("mybucket", "")
-if err != nil {
- fmt.Println(err)
- return
-}
-for resource, permission := range bucketPolicies {
- fmt.Println(resource, " => ", permission)
-}
-```
-
-<a name="GetBucketNotification"></a>
-### GetBucketNotification(bucketName string) (BucketNotification, error)
-Get notification configuration on a bucket.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketNotification` | _minio.BucketNotification_ |structure which holds all notification configurations|
-|`err` | _error_ |Standard Error |
-
-__Example__
-
-
-```go
-bucketNotification, err := minioClient.GetBucketNotification("mybucket")
-if err != nil {
- fmt.Println("Failed to get bucket notification configurations for mybucket", err)
- return
-}
-
-for _, queueConfig := range bucketNotification.QueueConfigs {
- for _, e := range queueConfig.Events {
- fmt.Println(e + " event is enabled")
- }
-}
-```
-
-<a name="SetBucketNotification"></a>
-### SetBucketNotification(bucketName string, bucketNotification BucketNotification) error
-Set a new bucket notification on a bucket.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-|`bucketNotification` | _minio.BucketNotification_ |Represents the XML to be sent to the configured web service |
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`err` | _error_ |Standard Error |
-
-__Example__
-
-
-```go
-queueArn := minio.NewArn("aws", "sqs", "us-east-1", "804605494417", "PhotoUpdate")
-
-queueConfig := minio.NewNotificationConfig(queueArn)
-queueConfig.AddEvents(minio.ObjectCreatedAll, minio.ObjectRemovedAll)
-queueConfig.AddFilterPrefix("photos/")
-queueConfig.AddFilterSuffix(".jpg")
-
-bucketNotification := minio.BucketNotification{}
-bucketNotification.AddQueue(queueConfig)
-
-err = minioClient.SetBucketNotification("mybucket", bucketNotification)
-if err != nil {
- fmt.Println("Unable to set the bucket notification: ", err)
- return
-}
-```
-
-<a name="RemoveAllBucketNotification"></a>
-### RemoveAllBucketNotification(bucketName string) error
-Remove all configured bucket notifications on a bucket.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ |Name of the bucket |
-
-__Return Values__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`err` | _error_ |Standard Error |
-
-__Example__
-
-
-```go
-err = minioClient.RemoveAllBucketNotification("mybucket")
-if err != nil {
- fmt.Println("Unable to remove bucket notifications.", err)
- return
-}
-```
-
-<a name="ListenBucketNotification"></a>
-### ListenBucketNotification(bucketName, prefix, suffix string, events []string, doneCh <-chan struct{}) <-chan NotificationInfo
-ListenBucketNotification API receives bucket notification events through the notification channel. The returned notification channel has two fields 'Records' and 'Err'.
-
-- 'Records' holds the notifications received from the server.
-- 'Err' indicates any error while processing the received notifications.
-
-NOTE: Notification channel is closed at the first occurrence of an error.
-
-__Parameters__
-
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`bucketName` | _string_ | Bucket to listen notifications on |
-|`prefix` | _string_ | Object key prefix to filter notifications for |
-|`suffix` | _string_ | Object key suffix to filter notifications for |
-|`events` | _[]string_ | Enables notifications for specific event types |
-|`doneCh` | _chan struct{}_ | A message on this channel ends the ListenBucketNotification iterator |
-
-__Return Values__
-
-|Param |Type |Description |
-|:---|:---| :---|
-|`notificationInfo` | _chan minio.NotificationInfo_ | Channel of bucket notifications |
-
-__minio.NotificationInfo__
-
-|Field |Type |Description |
-|`notificationInfo.Records` | _[]minio.NotificationEvent_ | Collection of notification events |
-|`notificationInfo.Err` | _error_ | Carries any error occurred during the operation (Standard Error) |
-
-
-__Example__
-
-
-```go
-// Create a done channel to control 'ListenBucketNotification' go routine.
-doneCh := make(chan struct{})
-
-// Indicate a background go-routine to exit cleanly upon return.
-defer close(doneCh)
-
-// Listen for bucket notifications on "mybucket" filtered by prefix, suffix and events.
-for notificationInfo := range minioClient.ListenBucketNotification("mybucket", "myprefix/", ".mysuffix", []string{
- "s3:ObjectCreated:*",
- "s3:ObjectAccessed:*",
- "s3:ObjectRemoved:*",
- }, doneCh) {
- if notificationInfo.Err != nil {
- fmt.Println(notificationInfo.Err)
- }
- fmt.Println(notificationInfo)
-}
-```
-
-## 7. Client custom settings
-
-<a name="SetAppInfo"></a>
-### SetAppInfo(appName, appVersion string)
-Add custom application details to User-Agent.
-
-__Parameters__
-
-| Param | Type | Description |
-|---|---|---|
-|`appName` | _string_ | Name of the application performing the API requests. |
-| `appVersion`| _string_ | Version of the application performing the API requests. |
-
-
-__Example__
-
-
-```go
-// Set Application name and version to be used in subsequent API requests.
-minioClient.SetAppInfo("myCloudApp", "1.0.0")
-```
-
-<a name="SetCustomTransport"></a>
-### SetCustomTransport(customHTTPTransport http.RoundTripper)
-Overrides default HTTP transport. This is usually needed for debugging or for adding custom TLS certificates.
-
-__Parameters__
-
-| Param | Type | Description |
-|---|---|---|
-|`customHTTPTransport` | _http.RoundTripper_ | Custom transport e.g, to trace API requests and responses for debugging purposes.|
-
-
-<a name="TraceOn"></a>
-### TraceOn(outputStream io.Writer)
-Enables HTTP tracing. The trace is written to the io.Writer provided. If outputStream is nil, trace is written to os.Stdout.
-
-__Parameters__
-
-| Param | Type | Description |
-|---|---|---|
-|`outputStream` | _io.Writer_ | HTTP trace is written into outputStream.|
-
-
-<a name="TraceOff"></a>
-### TraceOff()
-Disables HTTP tracing.
-
-<a name="SetS3TransferAccelerate"></a>
-### SetS3TransferAccelerate(acceleratedEndpoint string)
-Set AWS S3 transfer acceleration endpoint for all API requests hereafter.
-NOTE: This API applies only to AWS S3 and is a no operation for S3 compatible object storage services.
-
-__Parameters__
-
-| Param | Type | Description |
-|---|---|---|
-|`acceleratedEndpoint` | _string_ | Set to new S3 transfer acceleration endpoint.|
-
-
-## 8. Explore Further
-
-- [Build your own Go Music Player App example](https://docs.minio.io/docs/go-music-player-app)
diff --git a/vendor/github.com/minio/minio-go/docs/checker.go.template b/vendor/github.com/minio/minio-go/docs/checker.go.template
deleted file mode 100644
index 2e0f13a53..000000000
--- a/vendor/github.com/minio/minio-go/docs/checker.go.template
+++ /dev/null
@@ -1,21 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Use a secure connection.
- ssl := true
-
- // Initialize minio client object.
- minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- {{.Text}}
-}
diff --git a/vendor/github.com/minio/minio-go/docs/validator.go b/vendor/github.com/minio/minio-go/docs/validator.go
deleted file mode 100644
index 7d5cbaaab..000000000
--- a/vendor/github.com/minio/minio-go/docs/validator.go
+++ /dev/null
@@ -1,227 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
- "io/ioutil"
- "os"
- "os/exec"
- "path/filepath"
- "strings"
- "text/template"
-
- "github.com/a8m/mark"
- "github.com/gernest/wow"
- "github.com/gernest/wow/spin"
- "github.com/minio/cli"
-)
-
-func init() {
- // Validate go binary.
- if _, err := exec.LookPath("go"); err != nil {
- panic(err)
- }
-}
-
-var globalFlags = []cli.Flag{
- cli.StringFlag{
- Name: "m",
- Value: "API.md",
- Usage: "Path to markdown api documentation.",
- },
- cli.StringFlag{
- Name: "t",
- Value: "checker.go.template",
- Usage: "Template used for generating the programs.",
- },
- cli.IntFlag{
- Name: "skip",
- Value: 2,
- Usage: "Skip entries before validating the code.",
- },
-}
-
-func runGofmt(path string) (msg string, err error) {
- cmdArgs := []string{"-s", "-w", "-l", path}
- cmd := exec.Command("gofmt", cmdArgs...)
- stdoutStderr, err := cmd.CombinedOutput()
- if err != nil {
- return "", err
- }
- return string(stdoutStderr), nil
-}
-
-func runGoImports(path string) (msg string, err error) {
- cmdArgs := []string{"-w", path}
- cmd := exec.Command("goimports", cmdArgs...)
- stdoutStderr, err := cmd.CombinedOutput()
- if err != nil {
- return string(stdoutStderr), err
- }
- return string(stdoutStderr), nil
-}
-
-func runGoBuild(path string) (msg string, err error) {
- // Go build the path.
- cmdArgs := []string{"build", "-o", "/dev/null", path}
- cmd := exec.Command("go", cmdArgs...)
- stdoutStderr, err := cmd.CombinedOutput()
- if err != nil {
- return string(stdoutStderr), err
- }
- return string(stdoutStderr), nil
-}
-
-func validatorAction(ctx *cli.Context) error {
- if !ctx.IsSet("m") || !ctx.IsSet("t") {
- return nil
- }
- docPath := ctx.String("m")
- var err error
- docPath, err = filepath.Abs(docPath)
- if err != nil {
- return err
- }
- data, err := ioutil.ReadFile(docPath)
- if err != nil {
- return err
- }
-
- templatePath := ctx.String("t")
- templatePath, err = filepath.Abs(templatePath)
- if err != nil {
- return err
- }
-
- skipEntries := ctx.Int("skip")
- m := mark.New(string(data), &mark.Options{
- Gfm: true, // Github markdown support is enabled by default.
- })
-
- t, err := template.ParseFiles(templatePath)
- if err != nil {
- return err
- }
-
- tmpDir, err := ioutil.TempDir("", "md-verifier")
- if err != nil {
- return err
- }
- defer os.RemoveAll(tmpDir)
-
- entryN := 1
- for i := mark.NodeText; i < mark.NodeCheckbox; i++ {
- if mark.NodeCode != mark.NodeType(i) {
- m.AddRenderFn(mark.NodeType(i), func(node mark.Node) (s string) {
- return ""
- })
- continue
- }
- m.AddRenderFn(mark.NodeCode, func(node mark.Node) (s string) {
- p, ok := node.(*mark.CodeNode)
- if !ok {
- return
- }
- p.Text = strings.NewReplacer("&lt;", "<", "&gt;", ">", "&quot;", `"`, "&amp;", "&").Replace(p.Text)
- if skipEntries > 0 {
- skipEntries--
- return
- }
-
- testFilePath := filepath.Join(tmpDir, "example.go")
- w, werr := os.Create(testFilePath)
- if werr != nil {
- panic(werr)
- }
- t.Execute(w, p)
- w.Sync()
- w.Close()
- entryN++
-
- msg, err := runGofmt(testFilePath)
- if err != nil {
- fmt.Printf("Failed running gofmt on %s, with (%s):(%s)\n", testFilePath, msg, err)
- os.Exit(-1)
- }
-
- msg, err = runGoImports(testFilePath)
- if err != nil {
- fmt.Printf("Failed running gofmt on %s, with (%s):(%s)\n", testFilePath, msg, err)
- os.Exit(-1)
- }
-
- msg, err = runGoBuild(testFilePath)
- if err != nil {
- fmt.Printf("Failed running gobuild on %s, with (%s):(%s)\n", testFilePath, msg, err)
- fmt.Printf("Code with possible issue in %s:\n%s", docPath, p.Text)
- fmt.Printf("To test `go build %s`\n", testFilePath)
- os.Exit(-1)
- }
-
- // Once successfully built remove the test file
- os.Remove(testFilePath)
- return
- })
- }
-
- w := wow.New(os.Stdout, spin.Get(spin.Moon), fmt.Sprintf(" Running validation tests in %s", tmpDir))
-
- w.Start()
- // Render markdown executes our checker on each code blocks.
- _ = m.Render()
- w.PersistWith(spin.Get(spin.Runner), " Successfully finished tests")
- w.Stop()
-
- return nil
-}
-
-func main() {
- app := cli.NewApp()
- app.Action = validatorAction
- app.HideVersion = true
- app.HideHelpCommand = true
- app.Usage = "Validates code block sections inside API.md"
- app.Author = "Minio.io"
- app.Flags = globalFlags
- // Help template for validator
- app.CustomAppHelpTemplate = `NAME:
- {{.Name}} - {{.Usage}}
-
-USAGE:
- {{.Name}} {{if .VisibleFlags}}[FLAGS] {{end}}COMMAND{{if .VisibleFlags}} [COMMAND FLAGS | -h]{{end}} [ARGUMENTS...]
-
-COMMANDS:
- {{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
- {{end}}{{if .VisibleFlags}}
-FLAGS:
- {{range .VisibleFlags}}{{.}}
- {{end}}{{end}}
-TEMPLATE:
- Validator uses Go's 'text/template' formatting so you need to ensure
- your template is formatted correctly, check 'docs/checker.go.template'
-
-USAGE:
- go run docs/validator.go -m docs/API.md -t /tmp/mycode.go.template
-
-`
- app.Run(os.Args)
-
-}
diff --git a/vendor/github.com/minio/minio-go/docs/zh_CN/API.md b/vendor/github.com/minio/minio-go/docs/zh_CN/API.md
deleted file mode 100644
index d20ca102a..000000000
--- a/vendor/github.com/minio/minio-go/docs/zh_CN/API.md
+++ /dev/null
@@ -1,1820 +0,0 @@
-# Minio Go Client API文档 [![Slack](https://slack.minio.io/slack?type=svg)](https://slack.minio.io)
-
-## 初使化Minio Client对象。
-
-## Minio
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // 使用ssl
- ssl := true
-
- // 初使化minio client对象。
- minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
- if err != nil {
- fmt.Println(err)
- return
- }
-}
-```
-
-## AWS S3
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // 使用ssl
- ssl := true
-
- // 初使化minio client对象。
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ssl)
- if err != nil {
- fmt.Println(err)
- return
- }
-}
-```
-
-| 操作存储桶 | 操作对象 | 操作加密对象 | Presigned操作 | 存储桶策略/通知 | 客户端自定义设置 |
-| :--- | :--- | :--- | :--- | :--- | :--- |
-| [`MakeBucket`](#MakeBucket) | [`GetObject`](#GetObject) | [`NewSymmetricKey`](#NewSymmetricKey) | [`PresignedGetObject`](#PresignedGetObject) | [`SetBucketPolicy`](#SetBucketPolicy) | [`SetAppInfo`](#SetAppInfo) |
-| [`ListBuckets`](#ListBuckets) | [`PutObject`](#PutObject) | [`NewAsymmetricKey`](#NewAsymmetricKey) | [`PresignedPutObject`](#PresignedPutObject) | [`GetBucketPolicy`](#GetBucketPolicy) | [`SetCustomTransport`](#SetCustomTransport) |
-| [`BucketExists`](#BucketExists) | [`CopyObject`](#CopyObject) | [`GetEncryptedObject`](#GetEncryptedObject) | [`PresignedPostPolicy`](#PresignedPostPolicy) | [`ListBucketPolicies`](#ListBucketPolicies) | [`TraceOn`](#TraceOn) |
-| [`RemoveBucket`](#RemoveBucket) | [`StatObject`](#StatObject) | [`PutEncryptedObject`](#PutEncryptedObject) | | [`SetBucketNotification`](#SetBucketNotification) | [`TraceOff`](#TraceOff) |
-| [`ListObjects`](#ListObjects) | [`RemoveObject`](#RemoveObject) | [`NewSSEInfo`](#NewSSEInfo) | | [`GetBucketNotification`](#GetBucketNotification) | [`SetS3TransferAccelerate`](#SetS3TransferAccelerate) |
-| [`ListObjectsV2`](#ListObjectsV2) | [`RemoveObjects`](#RemoveObjects) | [`FPutEncryptedObject`](#FPutEncryptedObject) | | [`RemoveAllBucketNotification`](#RemoveAllBucketNotification) | |
-| [`ListIncompleteUploads`](#ListIncompleteUploads) | [`RemoveIncompleteUpload`](#RemoveIncompleteUpload) | | | [`ListenBucketNotification`](#ListenBucketNotification) | |
-| | [`FPutObject`](#FPutObject) | | | | |
-| | [`FGetObject`](#FGetObject) | | | | |
-| | [`ComposeObject`](#ComposeObject) | | | | |
-| | [`NewSourceInfo`](#NewSourceInfo) | | | | |
-| | [`NewDestinationInfo`](#NewDestinationInfo) | | | | |
-| | [`PutObjectWithContext`](#PutObjectWithContext) | | | |
-| | [`GetObjectWithContext`](#GetObjectWithContext) | | | |
-| | [`FPutObjectWithContext`](#FPutObjectWithContext) | | | |
-| | [`FGetObjectWithContext`](#FGetObjectWithContext) | | | |
-## 1. 构造函数
-<a name="Minio"></a>
-
-### New(endpoint, accessKeyID, secretAccessKey string, ssl bool) (*Client, error)
-初使化一个新的client对象。
-
-__参数__
-
-|参数 | 类型 |描述 |
-|:---|:---| :---|
-|`endpoint` | _string_ |S3兼容对象存储服务endpoint |
-|`accessKeyID` |_string_ |对象存储的Access key |
-|`secretAccessKey` | _string_ |对象存储的Secret key |
-|`ssl` | _bool_ |true代表使用HTTPS |
-
-### NewWithRegion(endpoint, accessKeyID, secretAccessKey string, ssl bool, region string) (*Client, error)
-初使化minio client,带有region配置。和New()不同的是,NewWithRegion避免了bucket-location操作,所以会快那么一丢丢。如果你的应用只使用一个region的话可以用这个方法。
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`endpoint` | _string_ |S3兼容对象存储服务endpoint |
-|`accessKeyID` |_string_ |对象存储的Access key |
-|`secretAccessKey` | _string_ |对象存储的Secret key |
-|`ssl` | _bool_ |true代表使用HTTPS |
-|`region`| _string_ | 对象存储的region |
-
-## 2. 操作存储桶
-
-<a name="MakeBucket"></a>
-### MakeBucket(bucketName, location string) error
-创建一个存储桶。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`bucketName` | _string_ | 存储桶名称 |
-| `location` | _string_ | 存储桶被创建的region(地区),默认是us-east-1(美国东一区),下面列举的是其它合法的值。注意:如果用的是minio服务的话,resion是在它的配置文件中,(默认是us-east-1)。|
-| | |us-east-1 |
-| | |us-west-1 |
-| | |us-west-2 |
-| | |eu-west-1 |
-| | | eu-central-1|
-| | | ap-southeast-1|
-| | | ap-northeast-1|
-| | | ap-southeast-2|
-| | | sa-east-1|
-
-
-__示例__
-
-
-```go
-err = minioClient.MakeBucket("mybucket", "us-east-1")
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully created mybucket.")
-```
-
-<a name="ListBuckets"></a>
-### ListBuckets() ([]BucketInfo, error)
-列出所有的存储桶。
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`bucketList` | _[]minio.BucketInfo_ | 所有存储桶的list。 |
-
-
-__minio.BucketInfo__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`bucket.Name` | _string_ | 存储桶名称 |
-|`bucket.CreationDate` | _time.Time_ | 存储桶的创建时间 |
-
-
-__示例__
-
-
-```go
-buckets, err := minioClient.ListBuckets()
-if err != nil {
- fmt.Println(err)
- return
-}
-for _, bucket := range buckets {
- fmt.Println(bucket)
-}
-```
-
-<a name="BucketExists"></a>
-### BucketExists(bucketName string) (found bool, err error)
-检查存储桶是否存在。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`found` | _bool_ | 存储桶是否存在 |
-|`err` | _error_ | 标准Error |
-
-
-__示例__
-
-
-```go
-found, err := minioClient.BucketExists("mybucket")
-if err != nil {
- fmt.Println(err)
- return
-}
-if found {
- fmt.Println("Bucket found")
-}
-```
-
-<a name="RemoveBucket"></a>
-### RemoveBucket(bucketName string) error
-删除一个存储桶,存储桶必须为空才能被成功删除。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-
-__示例__
-
-
-```go
-err = minioClient.RemoveBucket("mybucket")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="ListObjects"></a>
-### ListObjects(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
-列举存储桶里的对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectPrefix` |_string_ | 要列举的对象前缀 |
-|`recursive` | _bool_ |`true`代表递归查找,`false`代表类似文件夹查找,以'/'分隔,不查子文件夹。 |
-|`doneCh` | _chan struct{}_ | 在该channel上结束ListObjects iterator的一个message。 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`objectInfo` | _chan minio.ObjectInfo_ |存储桶中所有对象的read channel,对象的格式如下: |
-
-__minio.ObjectInfo__
-
-|属性 |类型 |描述 |
-|:---|:---| :---|
-|`objectInfo.Key` | _string_ |对象的名称 |
-|`objectInfo.Size` | _int64_ |对象的大小 |
-|`objectInfo.ETag` | _string_ |对象的MD5校验码 |
-|`objectInfo.LastModified` | _time.Time_ |对象的最后修改时间 |
-
-
-```go
-// Create a done channel to control 'ListObjects' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true
-objectCh := minioClient.ListObjects("mybucket", "myprefix", isRecursive, doneCh)
-for object := range objectCh {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
-}
-```
-
-
-<a name="ListObjectsV2"></a>
-### ListObjectsV2(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
-使用listing API v2版本列举存储桶中的对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-| `objectPrefix` |_string_ | 要列举的对象前缀 |
-| `recursive` | _bool_ |`true`代表递归查找,`false`代表类似文件夹查找,以'/'分隔,不查子文件夹。 |
-|`doneCh` | _chan struct{}_ | 在该channel上结束ListObjects iterator的一个message。 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`objectInfo` | _chan minio.ObjectInfo_ |存储桶中所有对象的read channel |
-
-
-```go
-// Create a done channel to control 'ListObjectsV2' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true
-objectCh := minioClient.ListObjectsV2("mybucket", "myprefix", isRecursive, doneCh)
-for object := range objectCh {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
-}
-```
-
-<a name="ListIncompleteUploads"></a>
-### ListIncompleteUploads(bucketName, prefix string, recursive bool, doneCh chan struct{}) <- chan ObjectMultipartInfo
-列举存储桶中未完整上传的对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-| `prefix` |_string_ | 不完整上传的对象的前缀 |
-| `recursive` | _bool_ |`true`代表递归查找,`false`代表类似文件夹查找,以'/'分隔,不查子文件夹。 |
-|`doneCh` | _chan struct{}_ | 在该channel上结束ListIncompleteUploads iterator的一个message。 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`multiPartInfo` | _chan minio.ObjectMultipartInfo_ |multipart对象格式如下: |
-
-__minio.ObjectMultipartInfo__
-
-|属性 |类型 |描述 |
-|:---|:---| :---|
-|`multiPartObjInfo.Key` | _string_ |未完整上传的对象的名称 |
-|`multiPartObjInfo.UploadID` | _string_ |未完整上传的对象的Upload ID |
-|`multiPartObjInfo.Size` | _int64_ |未完整上传的对象的大小 |
-
-__示例__
-
-
-```go
-// Create a done channel to control 'ListObjects' go routine.
-doneCh := make(chan struct{})
-
-// Indicate to our routine to exit cleanly upon return.
-defer close(doneCh)
-
-isRecursive := true // Recursively list everything at 'myprefix'
-multiPartObjectCh := minioClient.ListIncompleteUploads("mybucket", "myprefix", isRecursive, doneCh)
-for multiPartObject := range multiPartObjectCh {
- if multiPartObject.Err != nil {
- fmt.Println(multiPartObject.Err)
- return
- }
- fmt.Println(multiPartObject)
-}
-```
-
-## 3. 操作对象
-
-<a name="GetObject"></a>
-### GetObject(bucketName, objectName string, opts GetObjectOptions) (*Object, error)
-返回对象数据的流,error是读流时经常抛的那些错。
-
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`opts` | _minio.GetObjectOptions_ | GET请求的一些额外参数,像encryption,If-Match |
-
-
-__minio.GetObjectOptions__
-
-|参数 | 类型 | 描述 |
-|:---|:---|:---|
-| `opts.Materials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`object` | _*minio.Object_ |_minio.Object_代表了一个object reader。它实现了io.Reader, io.Seeker, io.ReaderAt and io.Closer接口。 |
-
-
-__示例__
-
-
-```go
-object, err := minioClient.GetObject("mybucket", "myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetObject"></a>
-### FGetObject(bucketName, objectName, filePath string, opts GetObjectOptions) error
-下载并将文件保存到本地文件系统。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |下载后保存的路径 |
-|`opts` | _minio.GetObjectOptions_ | GET请求的一些额外参数,像encryption,If-Match |
-
-
-__示例__
-
-
-```go
-err = minioClient.FGetObject("mybucket", "myobject", "/tmp/myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-<a name="GetObjectWithContext"></a>
-### GetObjectWithContext(ctx context.Context, bucketName, objectName string, opts GetObjectOptions) (*Object, error)
-和GetObject操作是一样的,不过传入了取消请求的context。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |请求上下文(Request context) |
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`opts` | _minio.GetObjectOptions_ | GET请求的一些额外参数,像encryption,If-Match |
-
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`object` | _*minio.Object_ |_minio.Object_代表了一个object reader。它实现了io.Reader, io.Seeker, io.ReaderAt and io.Closer接口。 |
-
-
-__示例__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-object, err := minioClient.GetObjectWithContext(ctx, "mybucket", "myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetObjectWithContext"></a>
-### FGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error
-和FGetObject操作是一样的,不过允许取消请求。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |请求上下文 |
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |下载后保存的路径 |
-|`opts` | _minio.GetObjectOptions_ | GET请求的一些额外参数,像encryption,If-Match |
-
-
-__示例__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-err = minioClient.FGetObjectWithContext(ctx, "mybucket", "myobject", "/tmp/myobject", minio.GetObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FGetEncryptedObject"></a>
-### FGetEncryptedObject(bucketName, objectName, filePath string, materials encrypt.Materials) error
-和FGetObject操作是一样的,不过会对加密请求进行解密。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |下载后保存的路径|
-|`materials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-
-__示例__
-
-
-```go
-// Generate a master symmetric key
-key := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-err = minioClient.FGetEncryptedObject("mybucket", "myobject", "/tmp/myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="PutObject"></a>
-### PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,opts PutObjectOptions) (n int, err error)
-当对象小于64MiB时,直接在一次PUT请求里进行上传。当大于64MiB时,根据文件的实际大小,PutObject会自动地将对象进行拆分成64MiB一块或更大一些进行上传。对象的最大大小是5TB。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`reader` | _io.Reader_ |任意实现了io.Reader的GO类型 |
-|`objectSize`| _int64_ |上传的对象的大小,-1代表未知。 |
-|`opts` | _minio.PutObjectOptions_ | 允许用户设置可选的自定义元数据,内容标题,加密密钥和用于分段上传操作的线程数量。 |
-
-__minio.PutObjectOptions__
-
-|属性 | 类型 | 描述 |
-|:--- |:--- | :--- |
-| `opts.UserMetadata` | _map[string]string_ | 用户元数据的Map|
-| `opts.Progress` | _io.Reader_ | 获取上传进度的Reader |
-| `opts.ContentType` | _string_ | 对象的Content type, 例如"application/text" |
-| `opts.ContentEncoding` | _string_ | 对象的Content encoding,例如"gzip" |
-| `opts.ContentDisposition` | _string_ | 对象的Content disposition, "inline" |
-| `opts.CacheControl` | _string_ | 指定针对请求和响应的缓存机制,例如"max-age=600"|
-| `opts.EncryptMaterials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-
-__示例__
-
-
-```go
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-fileStat, err := file.Stat()
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.PutObject("mybucket", "myobject", file, fileStat.Size(), minio.PutObjectOptions{ContentType:"application/octet-stream"})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-API方法在minio-go SDK版本v3.0.3中提供的PutObjectWithSize,PutObjectWithMetadata,PutObjectStreaming和PutObjectWithProgress被替换为接受指向PutObjectOptions struct的指针的新的PutObject调用变体。
-
-<a name="PutObjectWithContext"></a>
-### PutObjectWithContext(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts PutObjectOptions) (n int, err error)
-和PutObject是一样的,不过允许取消请求。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |请求上下文 |
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`reader` | _io.Reader_ |任何实现io.Reader的Go类型 |
-|`objectSize`| _int64_ | 上传的对象的大小,-1代表未知 |
-|`opts` | _minio.PutObjectOptions_ |允许用户设置可选的自定义元数据,content-type,content-encoding,content-disposition以及cache-control headers,传递加密模块以加密对象,并可选地设置multipart put操作的线程数量。|
-
-
-__示例__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 10 * time.Second)
-defer cancel()
-
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-fileStat, err := file.Stat()
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.PutObjectWithContext(ctx, "my-bucketname", "my-objectname", file, fileStat.Size(), minio.PutObjectOptions{
- ContentType: "application/octet-stream",
-})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="CopyObject"></a>
-### CopyObject(dst DestinationInfo, src SourceInfo) error
-通过在服务端对已存在的对象进行拷贝,实现新建或者替换对象。它支持有条件的拷贝,拷贝对象的一部分,以及在服务端的加解密。请查看`SourceInfo`和`DestinationInfo`两个类型来了解更多细节。
-
-拷贝多个源文件到一个目标对象,请查看`ComposeObject` API。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`dst` | _minio.DestinationInfo_ |目标对象 |
-|`src` | _minio.SourceInfo_ |源对象 |
-
-
-__示例__
-
-
-```go
-// Use-case 1: Simple copy object with no conditions.
-// Source object
-src := minio.NewSourceInfo("my-sourcebucketname", "my-sourceobjectname", nil)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-// Use-case 2:
-// Copy object with copy-conditions, and copying only part of the source object.
-// 1. that matches a given ETag
-// 2. and modified after 1st April 2014
-// 3. but unmodified since 23rd April 2014
-// 4. copy only first 1MiB of object.
-
-// Source object
-src := minio.NewSourceInfo("my-sourcebucketname", "my-sourceobjectname", nil)
-
-// Set matching ETag condition, copy object which matches the following ETag.
-src.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
-// Set modified condition, copy object modified since 2014 April 1.
-src.SetModifiedSinceCond(time.Date(2014, time.April, 1, 0, 0, 0, 0, time.UTC))
-
-// Set unmodified condition, copy object unmodified since 2014 April 23.
-src.SetUnmodifiedSinceCond(time.Date(2014, time.April, 23, 0, 0, 0, 0, time.UTC))
-
-// Set copy-range of only first 1MiB of file.
-src.SetRange(0, 1024*1024-1)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="ComposeObject"></a>
-### ComposeObject(dst minio.DestinationInfo, srcs []minio.SourceInfo) error
-通过使用服务端拷贝实现钭多个源对象合并创建成一个新的对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---|:---|
-|`dst` | _minio.DestinationInfo_ |要被创建的目标对象 |
-|`srcs` | _[]minio.SourceInfo_ |要合并的多个源对象 |
-
-
-__示例__
-
-
-```go
-// Prepare source decryption key (here we assume same key to
-// decrypt all source objects.)
-decKey := minio.NewSSEInfo([]byte{1, 2, 3}, "")
-
-// Source objects to concatenate. We also specify decryption
-// key for each
-src1 := minio.NewSourceInfo("bucket1", "object1", &decKey)
-src1.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
-src2 := minio.NewSourceInfo("bucket2", "object2", &decKey)
-src2.SetMatchETagCond("f8ef9c385918b653a31624deb84149d2")
-
-src3 := minio.NewSourceInfo("bucket3", "object3", &decKey)
-src3.SetMatchETagCond("5918b653a31624deb84149d2f8ef9c38")
-
-// Create slice of sources.
-srcs := []minio.SourceInfo{src1, src2, src3}
-
-// Prepare destination encryption key
-encKey := minio.NewSSEInfo([]byte{8, 9, 0}, "")
-
-// Create destination info
-dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Compose object call by concatenating multiple source files.
-err = minioClient.ComposeObject(dst, srcs)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-fmt.Println("Composed object successfully.")
-```
-
-<a name="NewSourceInfo"></a>
-### NewSourceInfo(bucket, object string, decryptSSEC *SSEInfo) SourceInfo
-构建一个可用于服务端拷贝操作(像`CopyObject`和`ComposeObject`)的`SourceInfo`对象。该对象可用于给源对象设置拷贝条件。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-| :--- | :--- | :--- |
-| `bucket` | _string_ | 源存储桶 |
-| `object` | _string_ | 源对象 |
-| `decryptSSEC` | _*minio.SSEInfo_ | 源对象的解密信息 (`nil`代表不用解密) |
-
-__示例__
-
-```go
-// No decryption parameter.
-src := minio.NewSourceInfo("bucket", "object", nil)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-// With decryption parameter.
-decKey := minio.NewSSEInfo([]byte{1,2,3}, "")
-src := minio.NewSourceInfo("bucket", "object", &decKey)
-
-// Destination object
-dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="NewDestinationInfo"></a>
-### NewDestinationInfo(bucket, object string, encryptSSEC *SSEInfo, userMeta map[string]string) (DestinationInfo, error)
-构建一个用于服务端拷贝操作(像`CopyObject`和`ComposeObject`)的用作目标对象的`DestinationInfo`。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-| :--- | :--- | :--- |
-| `bucket` | _string_ | 目标存储桶名称 |
-| `object` | _string_ | 目标对象名称 |
-| `encryptSSEC` | _*minio.SSEInfo_ | 源对象的加密信息 (`nil`代表不用加密) |
-| `userMeta` | _map[string]string_ | 给目标对象的用户元数据,如果是nil,并只有一个源对象,则将源对象的用户元数据拷贝给目标对象。|
-
-__示例__
-
-```go
-// No encryption parameter.
-src := minio.NewSourceInfo("bucket", "object", nil)
-dst, err := minio.NewDestinationInfo("bucket", "object", nil, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-```go
-src := minio.NewSourceInfo("bucket", "object", nil)
-
-// With encryption parameter.
-encKey := minio.NewSSEInfo([]byte{1,2,3}, "")
-dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Copy object call
-err = minioClient.CopyObject(dst, src)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="FPutObject"></a>
-### FPutObject(bucketName, objectName, filePath, opts PutObjectOptions) (length int64, err error)
-将filePath对应的文件内容上传到一个对象中。
-
-当对象小于64MiB时,FPutObject直接在一次PUT请求里进行上传。当大于64MiB时,根据文件的实际大小,FPutObject会自动地将对象进行拆分成64MiB一块或更大一些进行上传。对象的最大大小是5TB。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |要上传的文件的路径 |
-|`opts` | _minio.PutObjectOptions_ |允许用户设置可选的自定义元数据,content-type,content-encoding,content-disposition以及cache-control headers,传递加密模块以加密对象,并可选地设置multipart put操作的线程数量。 |
-
-
-__示例__
-
-
-```go
-n, err := minioClient.FPutObject("my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{
- ContentType: "application/csv",
-});
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="FPutObjectWithContext"></a>
-### FPutObjectWithContext(ctx context.Context, bucketName, objectName, filePath, opts PutObjectOptions) (length int64, err error)
-和FPutObject操作是一样的,不过允许取消请求。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`ctx` | _context.Context_ |请求上下文 |
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |要上传的文件的路径 |
-|`opts` | _minio.PutObjectOptions_ |允许用户设置可选的自定义元数据,content-type,content-encoding,content-disposition以及cache-control headers,传递加密模块以加密对象,并可选地设置multipart put操作的线程数量。 |
-
-__示例__
-
-
-```go
-ctx, cancel := context.WithTimeout(context.Background(), 100 * time.Second)
-defer cancel()
-
-n, err := minioClient.FPutObjectWithContext(ctx, "mybucket", "myobject.csv", "/tmp/otherobject.csv", minio.PutObjectOptions{ContentType:"application/csv"})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded bytes: ", n)
-```
-
-<a name="StatObject"></a>
-### StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error)
-获取对象的元数据。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`opts` | _minio.StatObjectOptions_ | GET info/stat请求的一些额外参数,像encryption,If-Match |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`objInfo` | _minio.ObjectInfo_ |对象stat信息 |
-
-
-__minio.ObjectInfo__
-
-|属性 |类型 |描述 |
-|:---|:---| :---|
-|`objInfo.LastModified` | _time.Time_ |对象的最后修改时间 |
-|`objInfo.ETag` | _string_ |对象的MD5校验码|
-|`objInfo.ContentType` | _string_ |对象的Content type|
-|`objInfo.Size` | _int64_ |对象的大小|
-
-
-__示例__
-
-
-```go
-objInfo, err := minioClient.StatObject("mybucket", "myobject", minio.StatObjectOptions{})
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println(objInfo)
-```
-
-<a name="RemoveObject"></a>
-### RemoveObject(bucketName, objectName string) error
-删除一个对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-
-
-```go
-err = minioClient.RemoveObject("mybucket", "myobject")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="RemoveObjects"></a>
-### RemoveObjects(bucketName string, objectsCh chan string) (errorCh <-chan RemoveObjectError)
-
-从一个input channel里删除一个对象集合。一次发送到服务端的删除请求最多可删除1000个对象。通过error channel返回的错误信息。
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectsCh` | _chan string_ | 要删除的对象的channel |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`errorCh` | _<-chan minio.RemoveObjectError_ | 删除时观察到的错误的Receive-only channel。 |
-
-
-```go
-objectsCh := make(chan string)
-
-// Send object names that are needed to be removed to objectsCh
-go func() {
- defer close(objectsCh)
- // List all objects from a bucket-name with a matching prefix.
- for object := range minioClient.ListObjects("my-bucketname", "my-prefixname", true, nil) {
- if object.Err != nil {
- log.Fatalln(object.Err)
- }
- objectsCh <- object.Key
- }
-}()
-
-for rErr := range minioClient.RemoveObjects("mybucket", objectsCh) {
- fmt.Println("Error detected during deletion: ", rErr)
-}
-```
-
-<a name="RemoveIncompleteUpload"></a>
-### RemoveIncompleteUpload(bucketName, objectName string) error
-删除一个未完整上传的对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-
-__示例__
-
-
-```go
-err = minioClient.RemoveIncompleteUpload("mybucket", "myobject")
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-## 4. 操作加密对象
-
-<a name="NewSymmetricKey"></a>
-### NewSymmetricKey(key []byte) *encrypt.SymmetricKey
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`key` | _string_ |存储桶名称 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`symmetricKey` | _*encrypt.SymmetricKey_ | 加密解密的对称秘钥 |
-
-```go
-symKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material with symmetric key.
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(symKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully initialized Symmetric key CBC materials", cbcMaterials)
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-```
-
-<a name="NewAsymmetricKey"></a>
-### NewAsymmetricKey(privateKey []byte, publicKey[]byte) (*encrypt.AsymmetricKey, error)
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`privateKey` | _[]byte_ | Private key数据 |
-|`publicKey` | _[]byte_ | Public key数据 |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`asymmetricKey` | _*encrypt.AsymmetricKey_ | 加密解密的非对称秘钥 |
-|`err` | _error_ | 标准Error |
-
-
-```go
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Initialize the asymmetric key
-asymmetricKey, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption material for asymmetric key.
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(asymmetricKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully initialized Asymmetric key CBC materials", cbcMaterials)
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-```
-
-<a name="GetEncryptedObject"></a>
-### GetEncryptedObject(bucketName, objectName string, encryptMaterials encrypt.Materials) (io.ReadCloser, error)
-
-返回对象的解密流。读流时的常见错误。
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ | 存储桶名称 |
-|`objectName` | _string_ | 对象的名称 |
-|`encryptMaterials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`stream` | _io.ReadCloser_ | 返回对象的reader,调用者需要在读取之后进行关闭。 |
-|`err` | _error | 错误信息 |
-
-
-__示例__
-
-
-```go
-// Generate a master symmetric key
-key := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
-// Build the CBC encryption material
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-object, err := minioClient.GetEncryptedObject("mybucket", "myobject", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-defer object.Close()
-
-localFile, err := os.Create("/tmp/local-file.jpg")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer localFile.Close()
-
-if _, err = io.Copy(localFile, object); err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="PutEncryptedObject"></a>
-
-### PutEncryptedObject(bucketName, objectName string, reader io.Reader, encryptMaterials encrypt.Materials) (n int, err error)
-加密并上传对象。
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`reader` | _io.Reader_ |任何实现io.Reader的Go类型 |
-|`encryptMaterials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-__示例__
-
-```go
-// Load a private key
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Load a public key
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build an asymmetric key
-key, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption module
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Open a file to upload
-file, err := os.Open("my-testfile")
-if err != nil {
- fmt.Println(err)
- return
-}
-defer file.Close()
-
-// Upload the encrypted form of the file
-n, err := minioClient.PutEncryptedObject("mybucket", "myobject", file, cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded encrypted bytes: ", n)
-```
-
-<a name="FPutEncryptedObject"></a>
-### FPutEncryptedObject(bucketName, objectName, filePath, encryptMaterials encrypt.Materials) (n int, err error)
-通过一个文件进行加密并上传到对象。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`filePath` | _string_ |要上传的文件的路径 |
-|`encryptMaterials` | _encrypt.Materials_ | `encrypt`包提供的对流加密的接口,(更多信息,请看https://godoc.org/github.com/minio/minio-go) |
-
-__示例__
-
-
-```go
-// Load a private key
-privateKey, err := ioutil.ReadFile("private.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Load a public key
-publicKey, err := ioutil.ReadFile("public.key")
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build an asymmetric key
-key, err := encrypt.NewAsymmetricKey(privateKey, publicKey)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// Build the CBC encryption module
-cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-n, err := minioClient.FPutEncryptedObject("mybucket", "myobject.csv", "/tmp/otherobject.csv", cbcMaterials)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully uploaded encrypted bytes: ", n)
-```
-
-<a name="NewSSEInfo"></a>
-
-### NewSSEInfo(key []byte, algo string) SSEInfo
-创建一个通过用户提供的key(SSE-C),进行服务端加解密操作的key对象。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-| :--- | :--- | :--- |
-| `key` | _[]byte_ | 未编码的二进制key数组 |
-| `algo` | _string_ | 加密算法,可以为空(默认是`AES256`) |
-
-
-## 5. Presigned操作
-
-<a name="PresignedGetObject"></a>
-### PresignedGetObject(bucketName, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
-生成一个用于HTTP GET操作的presigned URL。浏览器/移动客户端可以在即使存储桶为私有的情况下也可以通过这个URL进行下载。这个presigned URL可以有一个过期时间,默认是7天。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`expiry` | _time.Duration_ |presigned URL的过期时间,单位是秒 |
-|`reqParams` | _url.Values_ |额外的响应头,支持_response-expires_, _response-content-type_, _response-cache-control_, _response-content-disposition_。 |
-
-
-__示例__
-
-
-```go
-// Set request parameters for content-disposition.
-reqParams := make(url.Values)
-reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
-// Generates a presigned url which expires in a day.
-presignedURL, err := minioClient.PresignedGetObject("mybucket", "myobject", time.Second * 24 * 60 * 60, reqParams)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedPutObject"></a>
-### PresignedPutObject(bucketName, objectName string, expiry time.Duration) (*url.URL, error)
-生成一个用于HTTP GET操作的presigned URL。浏览器/移动客户端可以在即使存储桶为私有的情况下也可以通过这个URL进行下载。这个presigned URL可以有一个过期时间,默认是7天。
-
-注意:你可以通过只指定对象名称上传到S3。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`expiry` | _time.Duration_ |presigned URL的过期时间,单位是秒 |
-
-
-__示例__
-
-
-```go
-// Generates a url which expires in a day.
-expiry := time.Second * 24 * 60 * 60 // 1 day.
-presignedURL, err := minioClient.PresignedPutObject("mybucket", "myobject", expiry)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedHeadObject"></a>
-### PresignedHeadObject(bucketName, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
-生成一个用于HTTP GET操作的presigned URL。浏览器/移动客户端可以在即使存储桶为私有的情况下也可以通过这个URL进行下载。这个presigned URL可以有一个过期时间,默认是7天。
-
-__参数__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectName` | _string_ |对象的名称 |
-|`expiry` | _time.Duration_ |presigned URL的过期时间,单位是秒 |
-|`reqParams` | _url.Values_ |额外的响应头,支持_response-expires_, _response-content-type_, _response-cache-control_, _response-content-disposition_。 |
-
-
-__示例__
-
-
-```go
-// Set request parameters for content-disposition.
-reqParams := make(url.Values)
-reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
-// Generates a presigned url which expires in a day.
-presignedURL, err := minioClient.PresignedHeadObject("mybucket", "myobject", time.Second * 24 * 60 * 60, reqParams)
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Successfully generated presigned URL", presignedURL)
-```
-
-<a name="PresignedPostPolicy"></a>
-### PresignedPostPolicy(PostPolicy) (*url.URL, map[string]string, error)
-允许给POST操作的presigned URL设置策略条件。这些策略包括比如,接收对象上传的存储桶名称,名称前缀,过期策略。
-
-```go
-// Initialize policy condition config.
-policy := minio.NewPostPolicy()
-
-// Apply upload policy restrictions:
-policy.SetBucket("mybucket")
-policy.SetKey("myobject")
-policy.SetExpires(time.Now().UTC().AddDate(0, 0, 10)) // expires in 10 days
-
-// Only allow 'png' images.
-policy.SetContentType("image/png")
-
-// Only allow content size in range 1KB to 1MB.
-policy.SetContentLengthRange(1024, 1024*1024)
-
-// Add a user metadata using the key "custom" and value "user"
-policy.SetUserMetadata("custom", "user")
-
-// Get the POST form key/value object:
-url, formData, err := minioClient.PresignedPostPolicy(policy)
-if err != nil {
- fmt.Println(err)
- return
-}
-
-// POST your content from the command line using `curl`
-fmt.Printf("curl ")
-for k, v := range formData {
- fmt.Printf("-F %s=%s ", k, v)
-}
-fmt.Printf("-F file=@/etc/bash.bashrc ")
-fmt.Printf("%s\n", url)
-```
-
-## 6. 存储桶策略/通知
-
-<a name="SetBucketPolicy"></a>
-### SetBucketPolicy(bucketname, objectPrefix string, policy policy.BucketPolicy) error
-给存储桶或者对象前缀设置访问权限。
-
-必须引入`github.com/minio/minio-go/pkg/policy`包。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称|
-|`objectPrefix` | _string_ |对象的名称前缀|
-|`policy` | _policy.BucketPolicy_ |Policy的取值如下: |
-| | | _policy.BucketPolicyNone_ |
-| | | _policy.BucketPolicyReadOnly_ |
-| | | _policy.BucketPolicyReadWrite_ |
-| | | _policy.BucketPolicyWriteOnly_ |
-
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`err` | _error_ |标准Error |
-
-
-__示例__
-
-
-```go
-// Sets 'mybucket' with a sub-directory 'myprefix' to be anonymously accessible for
-// both read and write operations.
-err = minioClient.SetBucketPolicy("mybucket", "myprefix", policy.BucketPolicyReadWrite)
-if err != nil {
- fmt.Println(err)
- return
-}
-```
-
-<a name="GetBucketPolicy"></a>
-### GetBucketPolicy(bucketName, objectPrefix string) (policy.BucketPolicy, error)
-获取存储桶或者对象前缀的访问权限。
-
-必须引入`github.com/minio/minio-go/pkg/policy`包。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectPrefix` | _string_ |该存储桶下的对象前缀 |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketPolicy` | _policy.BucketPolicy_ |取值如下: `none`, `readonly`, `readwrite`,或者`writeonly` |
-|`err` | _error_ |标准Error |
-
-__示例__
-
-
-```go
-bucketPolicy, err := minioClient.GetBucketPolicy("mybucket", "")
-if err != nil {
- fmt.Println(err)
- return
-}
-fmt.Println("Access permissions for mybucket is", bucketPolicy)
-```
-
-<a name="ListBucketPolicies"></a>
-### ListBucketPolicies(bucketName, objectPrefix string) (map[string]BucketPolicy, error)
-获取指定的存储桶和前缀的访问策略。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`objectPrefix` | _string_ |该存储桶下的对象前缀 |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketPolicies` | _map[string]minio.BucketPolicy_ |对象以及它们的权限的Map |
-|`err` | _error_ |标准Error |
-
-__示例__
-
-
-```go
-bucketPolicies, err := minioClient.ListBucketPolicies("mybucket", "")
-if err != nil {
- fmt.Println(err)
- return
-}
-for resource, permission := range bucketPolicies {
- fmt.Println(resource, " => ", permission)
-}
-```
-
-<a name="GetBucketNotification"></a>
-### GetBucketNotification(bucketName string) (BucketNotification, error)
-获取存储桶的通知配置
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketNotification` | _minio.BucketNotification_ |含有所有通知配置的数据结构|
-|`err` | _error_ |标准Error |
-
-__示例__
-
-
-```go
-bucketNotification, err := minioClient.GetBucketNotification("mybucket")
-if err != nil {
- fmt.Println("Failed to get bucket notification configurations for mybucket", err)
- return
-}
-
-for _, queueConfig := range bucketNotification.QueueConfigs {
- for _, e := range queueConfig.Events {
- fmt.Println(e + " event is enabled")
- }
-}
-```
-
-<a name="SetBucketNotification"></a>
-### SetBucketNotification(bucketName string, bucketNotification BucketNotification) error
-给存储桶设置新的通知
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-|`bucketNotification` | _minio.BucketNotification_ |发送给配置的web service的XML |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`err` | _error_ |标准Error |
-
-__示例__
-
-
-```go
-queueArn := minio.NewArn("aws", "sqs", "us-east-1", "804605494417", "PhotoUpdate")
-
-queueConfig := minio.NewNotificationConfig(queueArn)
-queueConfig.AddEvents(minio.ObjectCreatedAll, minio.ObjectRemovedAll)
-queueConfig.AddFilterPrefix("photos/")
-queueConfig.AddFilterSuffix(".jpg")
-
-bucketNotification := minio.BucketNotification{}
-bucketNotification.AddQueue(queueConfig)
-
-err = minioClient.SetBucketNotification("mybucket", bucketNotification)
-if err != nil {
- fmt.Println("Unable to set the bucket notification: ", err)
- return
-}
-```
-
-<a name="RemoveAllBucketNotification"></a>
-### RemoveAllBucketNotification(bucketName string) error
-删除存储桶上所有配置的通知
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ |存储桶名称 |
-
-__返回值__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`err` | _error_ |标准Error |
-
-__示例__
-
-
-```go
-err = minioClient.RemoveAllBucketNotification("mybucket")
-if err != nil {
- fmt.Println("Unable to remove bucket notifications.", err)
- return
-}
-```
-
-<a name="ListenBucketNotification"></a>
-### ListenBucketNotification(bucketName, prefix, suffix string, events []string, doneCh <-chan struct{}) <-chan NotificationInfo
-ListenBucketNotification API通过notification channel接收存储桶通知事件。返回的notification channel有两个属性,'Records'和'Err'。
-
-- 'Records'持有从服务器返回的通知信息。
-- 'Err'表示的是处理接收到的通知时报的任何错误。
-
-注意:一旦报错,notification channel就会关闭。
-
-__参数__
-
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`bucketName` | _string_ | 被监听通知的存储桶 |
-|`prefix` | _string_ | 过滤通知的对象前缀 |
-|`suffix` | _string_ | 过滤通知的对象后缀 |
-|`events` | _[]string_ | 开启指定事件类型的通知 |
-|`doneCh` | _chan struct{}_ | 在该channel上结束ListenBucketNotification iterator的一个message。 |
-
-__返回值__
-
-|参数 |类型 |描述 |
-|:---|:---| :---|
-|`notificationInfo` | _chan minio.NotificationInfo_ | 存储桶通知的channel |
-
-__minio.NotificationInfo__
-
-|属性 |类型 |描述 |
-|`notificationInfo.Records` | _[]minio.NotificationEvent_ | 通知事件的集合 |
-|`notificationInfo.Err` | _error_ | 操作时报的任何错误(标准Error) |
-
-
-__示例__
-
-
-```go
-// Create a done channel to control 'ListenBucketNotification' go routine.
-doneCh := make(chan struct{})
-
-// Indicate a background go-routine to exit cleanly upon return.
-defer close(doneCh)
-
-// Listen for bucket notifications on "mybucket" filtered by prefix, suffix and events.
-for notificationInfo := range minioClient.ListenBucketNotification("mybucket", "myprefix/", ".mysuffix", []string{
- "s3:ObjectCreated:*",
- "s3:ObjectAccessed:*",
- "s3:ObjectRemoved:*",
- }, doneCh) {
- if notificationInfo.Err != nil {
- fmt.Println(notificationInfo.Err)
- }
- fmt.Println(notificationInfo)
-}
-```
-
-## 7. 客户端自定义设置
-
-<a name="SetAppInfo"></a>
-### SetAppInfo(appName, appVersion string)
-给User-Agent添加的自定义应用信息。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`appName` | _string_ | 发请求的应用名称 |
-| `appVersion`| _string_ | 发请求的应用版本 |
-
-
-__示例__
-
-
-```go
-// Set Application name and version to be used in subsequent API requests.
-minioClient.SetAppInfo("myCloudApp", "1.0.0")
-```
-
-<a name="SetCustomTransport"></a>
-### SetCustomTransport(customHTTPTransport http.RoundTripper)
-重写默认的HTTP transport,通常用于调试或者添加自定义的TLS证书。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`customHTTPTransport` | _http.RoundTripper_ | 自定义的transport,例如:为了调试对API请求响应进行追踪。|
-
-
-<a name="TraceOn"></a>
-### TraceOn(outputStream io.Writer)
-开启HTTP tracing。追踪信息输出到io.Writer,如果outputstream为nil,则trace写入到os.Stdout标准输出。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`outputStream` | _io.Writer_ | HTTP trace写入到outputStream |
-
-
-<a name="TraceOff"></a>
-### TraceOff()
-关闭HTTP tracing。
-
-<a name="SetS3TransferAccelerate"></a>
-### SetS3TransferAccelerate(acceleratedEndpoint string)
-给后续所有API请求设置ASW S3传输加速endpoint。
-注意:此API仅对AWS S3有效,对其它S3兼容的对象存储服务不生效。
-
-__参数__
-
-| 参数 | 类型 | 描述 |
-|---|---|---|
-|`acceleratedEndpoint` | _string_ | 设置新的S3传输加速endpoint。|
-
-
-## 8. 了解更多
-
-- [用Go语言创建属于你的音乐播放器APP示例](https://docs.minio.io/docs/go-music-player-app)
diff --git a/vendor/github.com/minio/minio-go/docs/zh_CN/CONTRIBUTING.md b/vendor/github.com/minio/minio-go/docs/zh_CN/CONTRIBUTING.md
deleted file mode 100644
index bc408c611..000000000
--- a/vendor/github.com/minio/minio-go/docs/zh_CN/CONTRIBUTING.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-### 开发者指南
-
-``minio-go``欢迎你的贡献。为了让大家配合更加默契,我们做出如下约定:
-
-* fork项目并修改,我们鼓励大家使用pull requests进行代码相关的讨论。
- - Fork项目
- - 创建你的特性分支 (git checkout -b my-new-feature)
- - Commit你的修改(git commit -am 'Add some feature')
- - Push到远程分支(git push origin my-new-feature)
- - 创建一个Pull Request
-
-* 当你准备创建pull request时,请确保:
- - 写单元测试,如果你有什么疑问,请在pull request中提出来。
- - 运行`go fmt`
- - 将你的多个提交合并成一个提交: `git rebase -i`。你可以强制update你的pull request。
- - 确保`go test -race ./...`和`go build`完成。
- 注意:go test会进行功能测试,这需要你有一个AWS S3账号。将账户信息设为``ACCESS_KEY``和``SECRET_KEY``环境变量。如果想运行简版测试,请使用``go test -short -race ./...``。
-
-* 请阅读 [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments)
- - `minio-go`项目严格符合Golang风格
- - 如果您看到代码有问题,请随时发一个pull request
diff --git a/vendor/github.com/minio/minio-go/examples/minio/listenbucketnotification.go b/vendor/github.com/minio/minio-go/examples/minio/listenbucketnotification.go
deleted file mode 100644
index 4c48510da..000000000
--- a/vendor/github.com/minio/minio-go/examples/minio/listenbucketnotification.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- minioClient, err := minio.New("play.minio.io:9000", "YOUR-ACCESS", "YOUR-SECRET", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- // Create a done channel to control 'ListenBucketNotification' go routine.
- doneCh := make(chan struct{})
-
- // Indicate to our routine to exit cleanly upon return.
- defer close(doneCh)
-
- // Listen for bucket notifications on "mybucket" filtered by prefix, suffix and events.
- for notificationInfo := range minioClient.ListenBucketNotification("YOUR-BUCKET", "PREFIX", "SUFFIX", []string{
- "s3:ObjectCreated:*",
- "s3:ObjectAccessed:*",
- "s3:ObjectRemoved:*",
- }, doneCh) {
- if notificationInfo.Err != nil {
- log.Fatalln(notificationInfo.Err)
- }
- log.Println(notificationInfo)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/bucketexists.go b/vendor/github.com/minio/minio-go/examples/s3/bucketexists.go
deleted file mode 100644
index 20dea30a3..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/bucketexists.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- found, err := s3Client.BucketExists("my-bucketname")
- if err != nil {
- log.Fatalln(err)
- }
-
- if found {
- log.Println("Bucket found.")
- } else {
- log.Println("Bucket not found.")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/composeobject.go b/vendor/github.com/minio/minio-go/examples/s3/composeobject.go
deleted file mode 100644
index 2f76ff053..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/composeobject.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- minio "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Enable trace.
- // s3Client.TraceOn(os.Stderr)
-
- // Prepare source decryption key (here we assume same key to
- // decrypt all source objects.)
- decKey := minio.NewSSEInfo([]byte{1, 2, 3}, "")
-
- // Source objects to concatenate. We also specify decryption
- // key for each
- src1 := minio.NewSourceInfo("bucket1", "object1", &decKey)
- src1.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
- src2 := minio.NewSourceInfo("bucket2", "object2", &decKey)
- src2.SetMatchETagCond("f8ef9c385918b653a31624deb84149d2")
-
- src3 := minio.NewSourceInfo("bucket3", "object3", &decKey)
- src3.SetMatchETagCond("5918b653a31624deb84149d2f8ef9c38")
-
- // Create slice of sources.
- srcs := []minio.SourceInfo{src1, src2, src3}
-
- // Prepare destination encryption key
- encKey := minio.NewSSEInfo([]byte{8, 9, 0}, "")
-
- // Create destination info
- dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
- if err != nil {
- log.Fatalln(err)
- }
-
- err = s3Client.ComposeObject(dst, srcs)
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Composed object successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/copyobject.go b/vendor/github.com/minio/minio-go/examples/s3/copyobject.go
deleted file mode 100644
index a7c3eca45..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/copyobject.go
+++ /dev/null
@@ -1,75 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "time"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Enable trace.
- // s3Client.TraceOn(os.Stderr)
-
- // Source object
- src := minio.NewSourceInfo("my-sourcebucketname", "my-sourceobjectname", nil)
-
- // All following conditions are allowed and can be combined together.
-
- // Set modified condition, copy object modified since 2014 April.
- src.SetModifiedSinceCond(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
-
- // Set unmodified condition, copy object unmodified since 2014 April.
- // src.SetUnmodifiedSinceCond(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
-
- // Set matching ETag condition, copy object which matches the following ETag.
- // src.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
-
- // Set matching ETag except condition, copy object which does not match the following ETag.
- // src.SetMatchETagExceptCond("31624deb84149d2f8ef9c385918b653a")
-
- // Destination object
- dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Initiate copy object.
- err = s3Client.CopyObject(dst, src)
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Copied source object /my-sourcebucketname/my-sourceobjectname to destination /my-bucketname/my-objectname Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/fgetobject-context.go b/vendor/github.com/minio/minio-go/examples/s3/fgetobject-context.go
deleted file mode 100644
index 6004baa14..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/fgetobject-context.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "log"
- "time"
-
- "context"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
- // and my-filename.csv are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
-
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
- defer cancel()
-
- if err := s3Client.FGetObjectWithContext(ctx, "my-bucketname", "my-objectname", "my-filename.csv", minio.GetObjectOptions{}); err != nil {
- log.Fatalln(err)
- }
- log.Println("Successfully saved my-filename.csv")
-
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/fgetobject.go b/vendor/github.com/minio/minio-go/examples/s3/fgetobject.go
deleted file mode 100644
index 819a34f91..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/fgetobject.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
- // and my-filename.csv are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- if err := s3Client.FGetObject("my-bucketname", "my-objectname", "my-filename.csv", minio.GetObjectOptions{}); err != nil {
- log.Fatalln(err)
- }
- log.Println("Successfully saved my-filename.csv")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/fputencrypted-object.go b/vendor/github.com/minio/minio-go/examples/s3/fputencrypted-object.go
deleted file mode 100644
index 96eec7e8f..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/fputencrypted-object.go
+++ /dev/null
@@ -1,80 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "log"
-
- "github.com/minio/minio-go"
- "github.com/minio/minio-go/pkg/encrypt"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Specify a local file that we will upload
- filePath := "my-testfile"
-
- //// Build an asymmetric key from private and public files
- //
- // privateKey, err := ioutil.ReadFile("private.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // publicKey, err := ioutil.ReadFile("public.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // asymmetricKey, err := NewAsymmetricKey(privateKey, publicKey)
- // if err != nil {
- // t.Fatal(err)
- // }
- ////
-
- // Build a symmetric key
- symmetricKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
- // Build encryption materials which will encrypt uploaded data
- cbcMaterials, err := encrypt.NewCBCSecureMaterials(symmetricKey)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Encrypt file content and upload to the server
- n, err := s3Client.FPutEncryptedObject("my-bucketname", "my-objectname", filePath, cbcMaterials)
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/fputobject-context.go b/vendor/github.com/minio/minio-go/examples/s3/fputobject-context.go
deleted file mode 100644
index d7c941c2b..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/fputobject-context.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "log"
- "time"
-
- "context"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
- // and my-filename.csv are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
-
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
- defer cancel()
-
- if _, err := s3Client.FPutObjectWithContext(ctx, "my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{ContentType: "application/csv"}); err != nil {
- log.Fatalln(err)
- }
- log.Println("Successfully uploaded my-filename.csv")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/fputobject.go b/vendor/github.com/minio/minio-go/examples/s3/fputobject.go
deleted file mode 100644
index 34d876804..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/fputobject.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
- // and my-filename.csv are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- if _, err := s3Client.FPutObject("my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{
- ContentType: "application/csv",
- }); err != nil {
- log.Fatalln(err)
- }
- log.Println("Successfully uploaded my-filename.csv")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go b/vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go
deleted file mode 100644
index 9783bebe8..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/get-encrypted-object.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "io"
- "log"
- "os"
-
- "github.com/minio/minio-go"
- "github.com/minio/minio-go/pkg/encrypt"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname and
- // my-testfile are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- //// Build an asymmetric key from private and public files
- //
- // privateKey, err := ioutil.ReadFile("private.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // publicKey, err := ioutil.ReadFile("public.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // asymmetricKey, err := NewAsymmetricKey(privateKey, publicKey)
- // if err != nil {
- // t.Fatal(err)
- // }
- ////
-
- // Build a symmetric key
- symmetricKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
- // Build encryption materials which will encrypt uploaded data
- cbcMaterials, err := encrypt.NewCBCSecureMaterials(symmetricKey)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Get a deciphered data from the server, deciphering is assured by cbcMaterials
- reader, err := s3Client.GetEncryptedObject("my-bucketname", "my-objectname", cbcMaterials)
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- // Local file which holds plain data
- localFile, err := os.Create("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer localFile.Close()
-
- if _, err := io.Copy(localFile, reader); err != nil {
- log.Fatalln(err)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/getbucketnotification.go b/vendor/github.com/minio/minio-go/examples/s3/getbucketnotification.go
deleted file mode 100644
index 19349baaf..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/getbucketnotification.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- notifications, err := s3Client.GetBucketNotification("my-bucketname")
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Bucket notification are successfully retrieved.")
-
- for _, topicConfig := range notifications.TopicConfigs {
- for _, e := range topicConfig.Events {
- log.Println(e + " event is enabled.")
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/getbucketpolicy.go b/vendor/github.com/minio/minio-go/examples/s3/getbucketpolicy.go
deleted file mode 100644
index f9ac89b61..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/getbucketpolicy.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- // Fetch the policy at 'my-objectprefix'.
- policy, err := s3Client.GetBucketPolicy("my-bucketname", "my-objectprefix")
- if err != nil {
- log.Fatalln(err)
- }
-
- // Description of policy output.
- // "none" - The specified bucket does not have a bucket policy.
- // "readonly" - Read only operations are allowed.
- // "writeonly" - Write only operations are allowed.
- // "readwrite" - both read and write operations are allowed, the bucket is public.
- log.Println("Success - ", policy)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/getobject-context.go b/vendor/github.com/minio/minio-go/examples/s3/getobject-context.go
deleted file mode 100644
index c7d41707a..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/getobject-context.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "io"
- "log"
- "os"
- "time"
-
- "context"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname and
- // my-testfile are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
-
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
- defer cancel()
-
- opts := minio.GetObjectOptions{}
- opts.SetModified(time.Now().Round(10 * time.Minute)) // get object if was modified within the last 10 minutes
- reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname", opts)
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- localFile, err := os.Create("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer localFile.Close()
-
- stat, err := reader.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- if _, err := io.CopyN(localFile, reader, stat.Size); err != nil {
- log.Fatalln(err)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/getobject.go b/vendor/github.com/minio/minio-go/examples/s3/getobject.go
deleted file mode 100644
index e17ef8172..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/getobject.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "io"
- "log"
- "os"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname and
- // my-testfile are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- reader, err := s3Client.GetObject("my-bucketname", "my-objectname", minio.GetObjectOptions{})
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- localFile, err := os.Create("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer localFile.Close()
-
- stat, err := reader.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- if _, err := io.CopyN(localFile, reader, stat.Size); err != nil {
- log.Fatalln(err)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listbucketpolicies.go b/vendor/github.com/minio/minio-go/examples/s3/listbucketpolicies.go
deleted file mode 100644
index 43edd0c3d..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listbucketpolicies.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- // Fetch the policy at 'my-objectprefix'.
- policies, err := s3Client.ListBucketPolicies("my-bucketname", "my-objectprefix")
- if err != nil {
- log.Fatalln(err)
- }
-
- // ListBucketPolicies returns a map of objects policy rules and their associated permissions
- // e.g. mybucket/downloadfolder/* => readonly
- // mybucket/shared/* => readwrite
-
- for resource, permission := range policies {
- log.Println(resource, " => ", permission)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listbuckets.go b/vendor/github.com/minio/minio-go/examples/s3/listbuckets.go
deleted file mode 100644
index 5eae587b4..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listbuckets.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID and YOUR-SECRETACCESSKEY are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- buckets, err := s3Client.ListBuckets()
- if err != nil {
- log.Fatalln(err)
- }
- for _, bucket := range buckets {
- log.Println(bucket)
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listincompleteuploads.go b/vendor/github.com/minio/minio-go/examples/s3/listincompleteuploads.go
deleted file mode 100644
index a5a79b603..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listincompleteuploads.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Create a done channel to control 'ListObjects' go routine.
- doneCh := make(chan struct{})
-
- // Indicate to our routine to exit cleanly upon return.
- defer close(doneCh)
-
- // List all multipart uploads from a bucket-name with a matching prefix.
- for multipartObject := range s3Client.ListIncompleteUploads("my-bucketname", "my-prefixname", true, doneCh) {
- if multipartObject.Err != nil {
- fmt.Println(multipartObject.Err)
- return
- }
- fmt.Println(multipartObject)
- }
- return
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listobjects-N.go b/vendor/github.com/minio/minio-go/examples/s3/listobjects-N.go
deleted file mode 100644
index 55bceb470..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listobjects-N.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- // List 'N' number of objects from a bucket-name with a matching prefix.
- listObjectsN := func(bucket, prefix string, recursive bool, N int) (objsInfo []minio.ObjectInfo, err error) {
- // Create a done channel to control 'ListObjects' go routine.
- doneCh := make(chan struct{}, 1)
-
- // Free the channel upon return.
- defer close(doneCh)
-
- i := 1
- for object := range s3Client.ListObjects(bucket, prefix, recursive, doneCh) {
- if object.Err != nil {
- return nil, object.Err
- }
- i++
- // Verify if we have printed N objects.
- if i == N {
- // Indicate ListObjects go-routine to exit and stop
- // feeding the objectInfo channel.
- doneCh <- struct{}{}
- }
- objsInfo = append(objsInfo, object)
- }
- return objsInfo, nil
- }
-
- // List recursively first 100 entries for prefix 'my-prefixname'.
- recursive := true
- objsInfo, err := listObjectsN("my-bucketname", "my-prefixname", recursive, 100)
- if err != nil {
- fmt.Println(err)
- }
-
- // Print all the entries.
- fmt.Println(objsInfo)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listobjects.go b/vendor/github.com/minio/minio-go/examples/s3/listobjects.go
deleted file mode 100644
index 1da2e3faa..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listobjects.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- // Create a done channel to control 'ListObjects' go routine.
- doneCh := make(chan struct{})
-
- // Indicate to our routine to exit cleanly upon return.
- defer close(doneCh)
-
- // List all objects from a bucket-name with a matching prefix.
- for object := range s3Client.ListObjects("my-bucketname", "my-prefixname", true, doneCh) {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
- }
- return
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/listobjectsV2.go b/vendor/github.com/minio/minio-go/examples/s3/listobjectsV2.go
deleted file mode 100644
index 190aec36b..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/listobjectsV2.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- // Create a done channel to control 'ListObjects' go routine.
- doneCh := make(chan struct{})
-
- // Indicate to our routine to exit cleanly upon return.
- defer close(doneCh)
-
- // List all objects from a bucket-name with a matching prefix.
- for object := range s3Client.ListObjectsV2("my-bucketname", "my-prefixname", true, doneCh) {
- if object.Err != nil {
- fmt.Println(object.Err)
- return
- }
- fmt.Println(object)
- }
- return
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/makebucket.go b/vendor/github.com/minio/minio-go/examples/s3/makebucket.go
deleted file mode 100644
index 419c96cf2..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/makebucket.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- err = s3Client.MakeBucket("my-bucketname", "us-east-1")
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/presignedgetobject.go b/vendor/github.com/minio/minio-go/examples/s3/presignedgetobject.go
deleted file mode 100644
index fd7fb9e8d..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/presignedgetobject.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "net/url"
- "time"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Set request parameters
- reqParams := make(url.Values)
- reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
- // Gernerate presigned get object url.
- presignedURL, err := s3Client.PresignedGetObject("my-bucketname", "my-objectname", time.Duration(1000)*time.Second, reqParams)
- if err != nil {
- log.Fatalln(err)
- }
- log.Println(presignedURL)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/presignedheadobject.go b/vendor/github.com/minio/minio-go/examples/s3/presignedheadobject.go
deleted file mode 100644
index 8dbc0a4b7..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/presignedheadobject.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "net/url"
- "time"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Set request parameters
- reqParams := make(url.Values)
- reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
-
- // Gernerate presigned get object url.
- presignedURL, err := s3Client.PresignedHeadObject("my-bucketname", "my-objectname", time.Duration(1000)*time.Second, reqParams)
- if err != nil {
- log.Fatalln(err)
- }
- log.Println(presignedURL)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/presignedpostpolicy.go b/vendor/github.com/minio/minio-go/examples/s3/presignedpostpolicy.go
deleted file mode 100644
index 205ac95a3..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/presignedpostpolicy.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "fmt"
- "log"
- "time"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- policy := minio.NewPostPolicy()
- policy.SetBucket("my-bucketname")
- policy.SetKey("my-objectname")
- // Expires in 10 days.
- policy.SetExpires(time.Now().UTC().AddDate(0, 0, 10))
- // Returns form data for POST form request.
- url, formData, err := s3Client.PresignedPostPolicy(policy)
- if err != nil {
- log.Fatalln(err)
- }
- fmt.Printf("curl ")
- for k, v := range formData {
- fmt.Printf("-F %s=%s ", k, v)
- }
- fmt.Printf("-F file=@/etc/bash.bashrc ")
- fmt.Printf("%s\n", url)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/presignedputobject.go b/vendor/github.com/minio/minio-go/examples/s3/presignedputobject.go
deleted file mode 100644
index b2f8b4f82..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/presignedputobject.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "time"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- presignedURL, err := s3Client.PresignedPutObject("my-bucketname", "my-objectname", time.Duration(1000)*time.Second)
- if err != nil {
- log.Fatalln(err)
- }
- log.Println(presignedURL)
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/put-encrypted-object.go b/vendor/github.com/minio/minio-go/examples/s3/put-encrypted-object.go
deleted file mode 100644
index cdf09ac53..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/put-encrypted-object.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "os"
-
- "github.com/minio/minio-go"
- "github.com/minio/minio-go/pkg/encrypt"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Open a local file that we will upload
- file, err := os.Open("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer file.Close()
-
- //// Build an asymmetric key from private and public files
- //
- // privateKey, err := ioutil.ReadFile("private.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // publicKey, err := ioutil.ReadFile("public.key")
- // if err != nil {
- // t.Fatal(err)
- // }
- //
- // asymmetricKey, err := NewAsymmetricKey(privateKey, publicKey)
- // if err != nil {
- // t.Fatal(err)
- // }
- ////
-
- // Build a symmetric key
- symmetricKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
-
- // Build encryption materials which will encrypt uploaded data
- cbcMaterials, err := encrypt.NewCBCSecureMaterials(symmetricKey)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Encrypt file content and upload to the server
- n, err := s3Client.PutEncryptedObject("my-bucketname", "my-objectname", file, cbcMaterials)
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-context.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-context.go
deleted file mode 100644
index acc923f7e..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject-context.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "log"
- "os"
- "time"
-
- "context"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
-
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
- defer cancel()
-
- object, err := os.Open("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer object.Close()
-
- objectStat, err := object.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- n, err := s3Client.PutObjectWithContext(ctx, "my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{
- ContentType: "application/octet-stream",
- })
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-getobject-sse.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-getobject-sse.go
deleted file mode 100644
index 3d3b2fd2d..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject-getobject-sse.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 (
- "bytes"
- "crypto/md5"
- "encoding/base64"
- "io/ioutil"
- "log"
-
- minio "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- minioClient, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- content := bytes.NewReader([]byte("Hello again"))
- key := []byte("32byteslongsecretkeymustprovided")
- h := md5.New()
- h.Write(key)
- encryptionKey := base64.StdEncoding.EncodeToString(key)
- encryptionKeyMD5 := base64.StdEncoding.EncodeToString(h.Sum(nil))
-
- // Amazon S3 does not store the encryption key you provide.
- // Instead S3 stores a randomly salted HMAC value of the
- // encryption key in order to validate future requests.
- // The salted HMAC value cannot be used to derive the value
- // of the encryption key or to decrypt the contents of the
- // encrypted object. That means, if you lose the encryption
- // key, you lose the object.
- var metadata = map[string]string{
- "x-amz-server-side-encryption-customer-algorithm": "AES256",
- "x-amz-server-side-encryption-customer-key": encryptionKey,
- "x-amz-server-side-encryption-customer-key-MD5": encryptionKeyMD5,
- }
-
- // minioClient.TraceOn(os.Stderr) // Enable to debug.
- _, err = minioClient.PutObject("mybucket", "my-encrypted-object.txt", content, 11, minio.PutObjectOptions{UserMetadata: metadata})
- if err != nil {
- log.Fatalln(err)
- }
-
- opts := minio.GetObjectOptions{}
- for k, v := range metadata {
- opts.Set(k, v)
- }
- coreClient := minio.Core{minioClient}
- reader, _, err := coreClient.GetObject("mybucket", "my-encrypted-object.txt", opts)
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- decBytes, err := ioutil.ReadAll(reader)
- if err != nil {
- log.Fatalln(err)
- }
- if !bytes.Equal(decBytes, []byte("Hello again")) {
- log.Fatalln("Expected \"Hello, world\", got %s", string(decBytes))
- }
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-progress.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-progress.go
deleted file mode 100644
index 0e92dd65e..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject-progress.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/cheggaaa/pb"
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- reader, err := s3Client.GetObject("my-bucketname", "my-objectname", minio.GetObjectOptions{})
- if err != nil {
- log.Fatalln(err)
- }
- defer reader.Close()
-
- objectInfo, err := reader.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- // Progress reader is notified as PutObject makes progress with
- // the Reads inside.
- progress := pb.New64(objectInfo.Size)
- progress.Start()
- n, err := s3Client.PutObject("my-bucketname", "my-objectname-progress", reader, objectInfo.Size, minio.PutObjectOptions{ContentType: "application/octet-stream", Progress: progress})
-
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go
deleted file mode 100644
index 06345cd87..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "os"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // Enable S3 transfer accelerate endpoint.
- s3Client.SetS3TransferAccelerate("s3-accelerate.amazonaws.com")
-
- object, err := os.Open("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer object.Close()
-
- objectStat, err := object.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{ContentType: "application/octet-stream"})
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-streaming.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-streaming.go
deleted file mode 100644
index 85b78dd45..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject-streaming.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "os"
-
- minio "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- object, err := os.Open("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer object.Close()
-
- n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, -1, minio.PutObjectOptions{})
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject.go b/vendor/github.com/minio/minio-go/examples/s3/putobject.go
deleted file mode 100644
index b9e4ff16c..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/putobject.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
- "os"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
- // my-objectname are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- object, err := os.Open("my-testfile")
- if err != nil {
- log.Fatalln(err)
- }
- defer object.Close()
- objectStat, err := object.Stat()
- if err != nil {
- log.Fatalln(err)
- }
-
- n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{ContentType: "application/octet-stream"})
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/removeallbucketnotification.go b/vendor/github.com/minio/minio-go/examples/s3/removeallbucketnotification.go
deleted file mode 100644
index 1186afad8..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/removeallbucketnotification.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- err = s3Client.RemoveAllBucketNotification("my-bucketname")
- if err != nil {
- log.Fatalln(err)
- }
-
- log.Println("Bucket notification are successfully removed.")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/removebucket.go b/vendor/github.com/minio/minio-go/examples/s3/removebucket.go
deleted file mode 100644
index 7a7737ee0..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/removebucket.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // This operation will only work if your bucket is empty.
- err = s3Client.RemoveBucket("my-bucketname")
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Success")
-
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/removeincompleteupload.go b/vendor/github.com/minio/minio-go/examples/s3/removeincompleteupload.go
deleted file mode 100644
index 31cc8790b..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/removeincompleteupload.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- err = s3Client.RemoveIncompleteUpload("my-bucketname", "my-objectname")
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/removeobject.go b/vendor/github.com/minio/minio-go/examples/s3/removeobject.go
deleted file mode 100644
index 7e5848576..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/removeobject.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
- err = s3Client.RemoveObject("my-bucketname", "my-objectname")
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/removeobjects.go b/vendor/github.com/minio/minio-go/examples/s3/removeobjects.go
deleted file mode 100644
index b912bc85d..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/removeobjects.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- objectsCh := make(chan string)
-
- // Send object names that are needed to be removed to objectsCh
- go func() {
- defer close(objectsCh)
- // List all objects from a bucket-name with a matching prefix.
- for object := range s3Client.ListObjects("my-bucketname", "my-prefixname", true, doneCh) {
- if object.Err != nil {
- log.Fatalln(object.Err)
- }
- objectsCh <- object.Key
- }
- }()
-
- // Call RemoveObjects API
- errorCh := s3Client.RemoveObjects("my-bucketname", objectsCh)
-
- // Print errors received from RemoveObjects API
- for e := range errorCh {
- log.Fatalln("Failed to remove " + e.ObjectName + ", error: " + e.Err.Error())
- }
-
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/setbucketnotification.go b/vendor/github.com/minio/minio-go/examples/s3/setbucketnotification.go
deleted file mode 100644
index b5af30f06..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/setbucketnotification.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- // ARN represents a notification channel that needs to be created in your S3 provider
- // (e.g. http://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html)
-
- // An example of an ARN:
- // arn:aws:sns:us-east-1:804064459714:UploadPhoto
- // ^ ^ ^ ^ ^
- // Provider __| | | | |
- // | Region Account ID |_ Notification Name
- // Service _|
- //
- // You should replace YOUR-PROVIDER, YOUR-SERVICE, YOUR-REGION, YOUR-ACCOUNT-ID and YOUR-RESOURCE
- // with actual values that you receive from the S3 provider
-
- // Here you create a new Topic notification
- topicArn := minio.NewArn("YOUR-PROVIDER", "YOUR-SERVICE", "YOUR-REGION", "YOUR-ACCOUNT-ID", "YOUR-RESOURCE")
- topicConfig := minio.NewNotificationConfig(topicArn)
- topicConfig.AddEvents(minio.ObjectCreatedAll, minio.ObjectRemovedAll)
- topicConfig.AddFilterPrefix("photos/")
- topicConfig.AddFilterSuffix(".jpg")
-
- // Create a new Queue notification
- queueArn := minio.NewArn("YOUR-PROVIDER", "YOUR-SERVICE", "YOUR-REGION", "YOUR-ACCOUNT-ID", "YOUR-RESOURCE")
- queueConfig := minio.NewNotificationConfig(queueArn)
- queueConfig.AddEvents(minio.ObjectRemovedAll)
-
- // Create a new Lambda (CloudFunction)
- lambdaArn := minio.NewArn("YOUR-PROVIDER", "YOUR-SERVICE", "YOUR-REGION", "YOUR-ACCOUNT-ID", "YOUR-RESOURCE")
- lambdaConfig := minio.NewNotificationConfig(lambdaArn)
- lambdaConfig.AddEvents(minio.ObjectRemovedAll)
- lambdaConfig.AddFilterSuffix(".swp")
-
- // Now, set all previously created notification configs
- bucketNotification := minio.BucketNotification{}
- bucketNotification.AddTopic(topicConfig)
- bucketNotification.AddQueue(queueConfig)
- bucketNotification.AddLambda(lambdaConfig)
-
- err = s3Client.SetBucketNotification("YOUR-BUCKET", bucketNotification)
- if err != nil {
- log.Fatalln("Error: " + err.Error())
- }
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/setbucketpolicy.go b/vendor/github.com/minio/minio-go/examples/s3/setbucketpolicy.go
deleted file mode 100644
index c81fb5050..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/setbucketpolicy.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
- "github.com/minio/minio-go/pkg/policy"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
- // dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
-
- // s3Client.TraceOn(os.Stderr)
-
- // Description of policy input.
- // policy.BucketPolicyNone - Remove any previously applied bucket policy at a prefix.
- // policy.BucketPolicyReadOnly - Set read-only operations at a prefix.
- // policy.BucketPolicyWriteOnly - Set write-only operations at a prefix.
- // policy.BucketPolicyReadWrite - Set read-write operations at a prefix.
- err = s3Client.SetBucketPolicy("my-bucketname", "my-objectprefix", policy.BucketPolicyReadWrite)
- if err != nil {
- log.Fatalln(err)
- }
- log.Println("Success")
-}
diff --git a/vendor/github.com/minio/minio-go/examples/s3/statobject.go b/vendor/github.com/minio/minio-go/examples/s3/statobject.go
deleted file mode 100644
index 0b27a83b3..000000000
--- a/vendor/github.com/minio/minio-go/examples/s3/statobject.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// +build ignore
-
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 (
- "log"
-
- "github.com/minio/minio-go"
-)
-
-func main() {
- // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
- // are dummy values, please replace them with original values.
-
- // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
- // This boolean value is the last argument for New().
-
- // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
- // determined based on the Endpoint value.
- s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
- if err != nil {
- log.Fatalln(err)
- }
- stat, err := s3Client.StatObject("my-bucketname", "my-objectname", minio.StatObjectOptions{})
- if err != nil {
- log.Fatalln(err)
- }
- log.Println(stat)
-}
diff --git a/vendor/github.com/minio/minio-go/get-options_test.go b/vendor/github.com/minio/minio-go/get-options_test.go
deleted file mode 100644
index c5344a0c6..000000000
--- a/vendor/github.com/minio/minio-go/get-options_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 minio
-
-import (
- "fmt"
- "testing"
-)
-
-func TestSetHeader(t *testing.T) {
- testCases := []struct {
- start int64
- end int64
- errVal error
- expected string
- }{
- {0, 10, nil, "bytes=0-10"},
- {1, 10, nil, "bytes=1-10"},
- {5, 0, nil, "bytes=5-"},
- {0, -5, nil, "bytes=-5"},
- {0, 0, nil, "bytes=0-0"},
- {11, 10, fmt.Errorf("Invalid range specified: start=11 end=10"),
- ""},
- {-1, 10, fmt.Errorf("Invalid range specified: start=-1 end=10"), ""},
- {-1, 0, fmt.Errorf("Invalid range specified: start=-1 end=0"), ""},
- {1, -5, fmt.Errorf("Invalid range specified: start=1 end=-5"), ""},
- }
- for i, testCase := range testCases {
- opts := GetObjectOptions{}
- err := opts.SetRange(testCase.start, testCase.end)
- if err == nil && testCase.errVal != nil {
- t.Errorf("Test %d: Expected to fail with '%v' but it passed",
- i+1, testCase.errVal)
- } else if err != nil && testCase.errVal.Error() != err.Error() {
- t.Errorf("Test %d: Expected error '%v' but got error '%v'",
- i+1, testCase.errVal, err)
- } else if err == nil && opts.headers["Range"] != testCase.expected {
- t.Errorf("Test %d: Expected range header '%s', but got '%s'",
- i+1, testCase.expected, opts.headers["Range"])
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/chain_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/chain_test.go
deleted file mode 100644
index d26e376ff..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/chain_test.go
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import (
- "errors"
- "testing"
-)
-
-type testCredProvider struct {
- creds Value
- expired bool
- err error
-}
-
-func (s *testCredProvider) Retrieve() (Value, error) {
- s.expired = false
- return s.creds, s.err
-}
-func (s *testCredProvider) IsExpired() bool {
- return s.expired
-}
-
-func TestChainGet(t *testing.T) {
- p := &Chain{
- Providers: []Provider{
- &credProvider{err: errors.New("FirstError")},
- &credProvider{err: errors.New("SecondError")},
- &testCredProvider{
- creds: Value{
- AccessKeyID: "AKIF",
- SecretAccessKey: "NOSECRET",
- SessionToken: "",
- },
- },
- &credProvider{
- creds: Value{
- AccessKeyID: "AKID",
- SecretAccessKey: "SECRET",
- SessionToken: "",
- },
- },
- },
- }
-
- creds, err := p.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- // Also check credentials
- if creds.AccessKeyID != "AKIF" {
- t.Fatalf("Expected 'AKIF', got %s", creds.AccessKeyID)
- }
- if creds.SecretAccessKey != "NOSECRET" {
- t.Fatalf("Expected 'NOSECRET', got %s", creds.SecretAccessKey)
- }
- if creds.SessionToken != "" {
- t.Fatalf("Expected empty token, got %s", creds.SessionToken)
- }
-}
-
-func TestChainIsExpired(t *testing.T) {
- credProvider := &credProvider{
- creds: Value{
- AccessKeyID: "UXHW",
- SecretAccessKey: "MYSECRET",
- SessionToken: "",
- },
- expired: true,
- }
- p := &Chain{
- Providers: []Provider{
- credProvider,
- },
- }
-
- if !p.IsExpired() {
- t.Fatal("Expected expired to be true before any Retrieve")
- }
-
- _, err := p.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- if p.IsExpired() {
- t.Fatal("Expected to be not expired after Retrieve")
- }
-}
-
-func TestChainWithNoProvider(t *testing.T) {
- p := &Chain{
- Providers: []Provider{},
- }
- if !p.IsExpired() {
- t.Fatal("Expected to be expired with no providers")
- }
- _, err := p.Retrieve()
- if err != nil {
- if err.Error() != "No valid providers found []" {
- t.Error(err)
- }
- }
-}
-
-func TestChainProviderWithNoValidProvider(t *testing.T) {
- errs := []error{
- errors.New("FirstError"),
- errors.New("SecondError"),
- }
- p := &Chain{
- Providers: []Provider{
- &credProvider{err: errs[0]},
- &credProvider{err: errs[1]},
- },
- }
-
- if !p.IsExpired() {
- t.Fatal("Expected to be expired with no providers")
- }
-
- _, err := p.Retrieve()
- if err != nil {
- if err.Error() != "No valid providers found [FirstError SecondError]" {
- t.Error(err)
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/credentials_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/credentials_test.go
deleted file mode 100644
index 92c77c4cb..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/credentials_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import (
- "errors"
- "testing"
-)
-
-type credProvider struct {
- creds Value
- expired bool
- err error
-}
-
-func (s *credProvider) Retrieve() (Value, error) {
- s.expired = false
- return s.creds, s.err
-}
-func (s *credProvider) IsExpired() bool {
- return s.expired
-}
-
-func TestCredentialsGet(t *testing.T) {
- c := New(&credProvider{
- creds: Value{
- AccessKeyID: "UXHW",
- SecretAccessKey: "MYSECRET",
- SessionToken: "",
- },
- expired: true,
- })
-
- creds, err := c.Get()
- if err != nil {
- t.Fatal(err)
- }
- if "UXHW" != creds.AccessKeyID {
- t.Errorf("Expected \"UXHW\", got %s", creds.AccessKeyID)
- }
- if "MYSECRET" != creds.SecretAccessKey {
- t.Errorf("Expected \"MYSECRET\", got %s", creds.SecretAccessKey)
- }
- if creds.SessionToken != "" {
- t.Errorf("Expected session token to be empty, got %s", creds.SessionToken)
- }
-}
-
-func TestCredentialsGetWithError(t *testing.T) {
- c := New(&credProvider{err: errors.New("Custom error")})
-
- _, err := c.Get()
- if err != nil {
- if err.Error() != "Custom error" {
- t.Errorf("Expected \"Custom error\", got %s", err.Error())
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/env_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/env_test.go
deleted file mode 100644
index 09cd77f7a..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/env_test.go
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import (
- "os"
- "reflect"
- "testing"
-)
-
-func TestEnvAWSRetrieve(t *testing.T) {
- os.Clearenv()
- os.Setenv("AWS_ACCESS_KEY_ID", "access")
- os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
- os.Setenv("AWS_SESSION_TOKEN", "token")
-
- e := EnvAWS{}
- if !e.IsExpired() {
- t.Error("Expect creds to be expired before retrieve.")
- }
-
- creds, err := e.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- expectedCreds := Value{
- AccessKeyID: "access",
- SecretAccessKey: "secret",
- SessionToken: "token",
- SignerType: SignatureV4,
- }
- if !reflect.DeepEqual(creds, expectedCreds) {
- t.Errorf("Expected %v, got %v", expectedCreds, creds)
- }
-
- if e.IsExpired() {
- t.Error("Expect creds to not be expired after retrieve.")
- }
-
- os.Clearenv()
- os.Setenv("AWS_ACCESS_KEY", "access")
- os.Setenv("AWS_SECRET_KEY", "secret")
-
- expectedCreds = Value{
- AccessKeyID: "access",
- SecretAccessKey: "secret",
- SignerType: SignatureV4,
- }
-
- creds, err = e.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- if !reflect.DeepEqual(creds, expectedCreds) {
- t.Errorf("Expected %v, got %v", expectedCreds, creds)
- }
-
-}
-
-func TestEnvMinioRetrieve(t *testing.T) {
- os.Clearenv()
-
- os.Setenv("MINIO_ACCESS_KEY", "access")
- os.Setenv("MINIO_SECRET_KEY", "secret")
-
- e := EnvMinio{}
- if !e.IsExpired() {
- t.Error("Expect creds to be expired before retrieve.")
- }
-
- creds, err := e.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- expectedCreds := Value{
- AccessKeyID: "access",
- SecretAccessKey: "secret",
- SignerType: SignatureV4,
- }
- if !reflect.DeepEqual(creds, expectedCreds) {
- t.Errorf("Expected %v, got %v", expectedCreds, creds)
- }
-
- if e.IsExpired() {
- t.Error("Expect creds to not be expired after retrieve.")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/file_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/file_test.go
deleted file mode 100644
index c85c10494..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/file_test.go
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import (
- "os"
- "path/filepath"
- "testing"
-)
-
-func TestFileAWS(t *testing.T) {
- os.Clearenv()
-
- creds := NewFileAWSCredentials("credentials.sample", "")
- credValues, err := creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SessionToken != "token" {
- t.Errorf("Expected 'token', got %s'", credValues.SessionToken)
- }
-
- os.Setenv("AWS_SHARED_CREDENTIALS_FILE", "credentials.sample")
- creds = NewFileAWSCredentials("", "")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SessionToken != "token" {
- t.Errorf("Expected 'token', got %s'", credValues.SessionToken)
- }
-
- wd, err := os.Getwd()
- if err != nil {
- t.Fatal(err)
- }
-
- os.Setenv("AWS_SHARED_CREDENTIALS_FILE", filepath.Join(wd, "credentials.sample"))
- creds = NewFileAWSCredentials("", "")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SessionToken != "token" {
- t.Errorf("Expected 'token', got %s'", credValues.SessionToken)
- }
-
- os.Clearenv()
- os.Setenv("AWS_PROFILE", "no_token")
-
- creds = NewFileAWSCredentials("credentials.sample", "")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
-
- os.Clearenv()
-
- creds = NewFileAWSCredentials("credentials.sample", "no_token")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
-
- creds = NewFileAWSCredentials("credentials-non-existent.sample", "no_token")
- _, err = creds.Get()
- if !os.IsNotExist(err) {
- t.Errorf("Expected open non-existent.json: no such file or directory, got %s", err)
- }
- if !creds.IsExpired() {
- t.Error("Should be expired if not loaded")
- }
-}
-
-func TestFileMinioClient(t *testing.T) {
- os.Clearenv()
-
- creds := NewFileMinioClient("config.json.sample", "")
- credValues, err := creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "accessKey" {
- t.Errorf("Expected 'accessKey', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "secret" {
- t.Errorf("Expected 'secret', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SignerType != SignatureV4 {
- t.Errorf("Expected 'S3v4', got %s'", credValues.SignerType)
- }
-
- os.Clearenv()
- os.Setenv("MINIO_ALIAS", "play")
-
- creds = NewFileMinioClient("config.json.sample", "")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "Q3AM3UQ867SPQQA43P2F" {
- t.Errorf("Expected 'Q3AM3UQ867SPQQA43P2F', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" {
- t.Errorf("Expected 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SignerType != SignatureV2 {
- t.Errorf("Expected 'S3v2', got %s'", credValues.SignerType)
- }
-
- os.Clearenv()
-
- creds = NewFileMinioClient("config.json.sample", "play")
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if credValues.AccessKeyID != "Q3AM3UQ867SPQQA43P2F" {
- t.Errorf("Expected 'Q3AM3UQ867SPQQA43P2F', got %s'", credValues.AccessKeyID)
- }
- if credValues.SecretAccessKey != "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" {
- t.Errorf("Expected 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG', got %s'", credValues.SecretAccessKey)
- }
- if credValues.SignerType != SignatureV2 {
- t.Errorf("Expected 'S3v2', got %s'", credValues.SignerType)
- }
-
- creds = NewFileMinioClient("non-existent.json", "play")
- _, err = creds.Get()
- if !os.IsNotExist(err) {
- t.Errorf("Expected open non-existent.json: no such file or directory, got %s", err)
- }
- if !creds.IsExpired() {
- t.Error("Should be expired if not loaded")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/iam_aws_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/iam_aws_test.go
deleted file mode 100644
index 86ea66bf6..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/iam_aws_test.go
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "testing"
- "time"
-)
-
-const credsRespTmpl = `{
- "Code": "Success",
- "Type": "AWS-HMAC",
- "AccessKeyId" : "accessKey",
- "SecretAccessKey" : "secret",
- "Token" : "token",
- "Expiration" : "%s",
- "LastUpdated" : "2009-11-23T0:00:00Z"
-}`
-
-const credsFailRespTmpl = `{
- "Code": "ErrorCode",
- "Message": "ErrorMsg",
- "LastUpdated": "2009-11-23T0:00:00Z"
-}`
-
-func initTestFailServer() *httptest.Server {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- http.Error(w, "Not allowed", http.StatusBadRequest)
- }))
- return server
-}
-
-func initTestServerNoRoles() *httptest.Server {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte(""))
- }))
- return server
-}
-
-func initTestServer(expireOn string, failAssume bool) *httptest.Server {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path == "/latest/meta-data/iam/security-credentials" {
- fmt.Fprintln(w, "RoleName")
- } else if r.URL.Path == "/latest/meta-data/iam/security-credentials/RoleName" {
- if failAssume {
- fmt.Fprintf(w, credsFailRespTmpl)
- } else {
- fmt.Fprintf(w, credsRespTmpl, expireOn)
- }
- } else {
- http.Error(w, "bad request", http.StatusBadRequest)
- }
- }))
-
- return server
-}
-
-func TestIAMMalformedEndpoint(t *testing.T) {
- creds := NewIAM("%%%%")
- _, err := creds.Get()
- if err == nil {
- t.Fatal("Unexpected should fail here")
- }
- if err.Error() != `parse %%%%: invalid URL escape "%%%"` {
- t.Fatalf("Expected parse %%%%%%%%: invalid URL escape \"%%%%%%\", got %s", err)
- }
-}
-
-func TestIAMFailServer(t *testing.T) {
- server := initTestFailServer()
- defer server.Close()
-
- creds := NewIAM(server.URL)
-
- _, err := creds.Get()
- if err == nil {
- t.Fatal("Unexpected should fail here")
- }
- if err.Error() != "400 Bad Request" {
- t.Fatalf("Expected '400 Bad Request', got %s", err)
- }
-}
-
-func TestIAMNoRoles(t *testing.T) {
- server := initTestServerNoRoles()
- defer server.Close()
-
- creds := NewIAM(server.URL)
- _, err := creds.Get()
- if err == nil {
- t.Fatal("Unexpected should fail here")
- }
- if err.Error() != "No IAM roles attached to this EC2 service" {
- t.Fatalf("Expected 'No IAM roles attached to this EC2 service', got %s", err)
- }
-}
-
-func TestIAM(t *testing.T) {
- server := initTestServer("2014-12-16T01:51:37Z", false)
- defer server.Close()
-
- p := &IAM{
- Client: http.DefaultClient,
- endpoint: server.URL,
- }
-
- creds, err := p.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- if "accessKey" != creds.AccessKeyID {
- t.Errorf("Expected \"accessKey\", got %s", creds.AccessKeyID)
- }
-
- if "secret" != creds.SecretAccessKey {
- t.Errorf("Expected \"secret\", got %s", creds.SecretAccessKey)
- }
-
- if "token" != creds.SessionToken {
- t.Errorf("Expected \"token\", got %s", creds.SessionToken)
- }
-
- if !p.IsExpired() {
- t.Error("Expected creds to be expired.")
- }
-}
-
-func TestIAMFailAssume(t *testing.T) {
- server := initTestServer("2014-12-16T01:51:37Z", true)
- defer server.Close()
-
- p := &IAM{
- Client: http.DefaultClient,
- endpoint: server.URL,
- }
-
- _, err := p.Retrieve()
- if err == nil {
- t.Fatal("Unexpected success, should fail")
- }
- if err.Error() != "ErrorMsg" {
- t.Errorf("Expected \"ErrorMsg\", got %s", err)
- }
-}
-
-func TestIAMIsExpired(t *testing.T) {
- server := initTestServer("2014-12-16T01:51:37Z", false)
- defer server.Close()
-
- p := &IAM{
- Client: http.DefaultClient,
- endpoint: server.URL,
- }
- p.CurrentTime = func() time.Time {
- return time.Date(2014, 12, 15, 21, 26, 0, 0, time.UTC)
- }
-
- if !p.IsExpired() {
- t.Error("Expected creds to be expired before retrieve.")
- }
-
- _, err := p.Retrieve()
- if err != nil {
- t.Fatal(err)
- }
-
- if p.IsExpired() {
- t.Error("Expected creds to not be expired after retrieve.")
- }
-
- p.CurrentTime = func() time.Time {
- return time.Date(3014, 12, 15, 21, 26, 0, 0, time.UTC)
- }
-
- if !p.IsExpired() {
- t.Error("Expected creds to be expired when curren time has changed")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/credentials/static_test.go b/vendor/github.com/minio/minio-go/pkg/credentials/static_test.go
deleted file mode 100644
index f1d2d856c..000000000
--- a/vendor/github.com/minio/minio-go/pkg/credentials/static_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 credentials
-
-import "testing"
-
-func TestStaticGet(t *testing.T) {
- creds := NewStatic("UXHW", "SECRET", "", SignatureV4)
- credValues, err := creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if "UXHW" != credValues.AccessKeyID {
- t.Errorf("Expected access key ID to match \"UXHW\", got %s", credValues.AccessKeyID)
- }
- if "SECRET" != credValues.SecretAccessKey {
- t.Errorf("Expected secret access key to match \"SECRET\", got %s", credValues.SecretAccessKey)
- }
-
- if credValues.SessionToken != "" {
- t.Error("Expected session token to match")
- }
-
- if credValues.SignerType != SignatureV4 {
- t.Errorf("Expected 'S3v4', got %s", credValues.SignerType)
- }
-
- if creds.IsExpired() {
- t.Error("Static credentials should never expire")
- }
-
- creds = NewStatic("", "", "", SignatureDefault)
- credValues, err = creds.Get()
- if err != nil {
- t.Fatal(err)
- }
-
- if "" != credValues.AccessKeyID {
- t.Errorf("Expected access key ID to match empty string, got %s", credValues.AccessKeyID)
- }
- if "" != credValues.SecretAccessKey {
- t.Errorf("Expected secret access key to match empty string, got %s", credValues.SecretAccessKey)
- }
-
- if !credValues.SignerType.IsAnonymous() {
- t.Errorf("Expected 'Anonymous', got %s", credValues.SignerType)
- }
-
- if creds.IsExpired() {
- t.Error("Static credentials should never expire")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy-condition_test.go b/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy-condition_test.go
deleted file mode 100644
index 9e4aa8fb6..000000000
--- a/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy-condition_test.go
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 policy
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/minio/minio-go/pkg/set"
-)
-
-// ConditionKeyMap.Add() is called and the result is validated.
-func TestConditionKeyMapAdd(t *testing.T) {
- condKeyMap := make(ConditionKeyMap)
- testCases := []struct {
- key string
- value set.StringSet
- expectedResult string
- }{
- // Add new key and value.
- {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello"]}`},
- // Add existing key and value.
- {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello"]}`},
- // Add existing key and not value.
- {"s3:prefix", set.CreateStringSet("world"), `{"s3:prefix":["hello","world"]}`},
- }
-
- for _, testCase := range testCases {
- condKeyMap.Add(testCase.key, testCase.value)
- if data, err := json.Marshal(condKeyMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// ConditionKeyMap.Remove() is called and the result is validated.
-func TestConditionKeyMapRemove(t *testing.T) {
- condKeyMap := make(ConditionKeyMap)
- condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
-
- testCases := []struct {
- key string
- value set.StringSet
- expectedResult string
- }{
- // Remove non-existent key and value.
- {"s3:myprefix", set.CreateStringSet("hello"), `{"s3:prefix":["hello","world"]}`},
- // Remove existing key and value.
- {"s3:prefix", set.CreateStringSet("hello"), `{"s3:prefix":["world"]}`},
- // Remove existing key to make the key also removed.
- {"s3:prefix", set.CreateStringSet("world"), `{}`},
- }
-
- for _, testCase := range testCases {
- condKeyMap.Remove(testCase.key, testCase.value)
- if data, err := json.Marshal(condKeyMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// ConditionKeyMap.RemoveKey() is called and the result is validated.
-func TestConditionKeyMapRemoveKey(t *testing.T) {
- condKeyMap := make(ConditionKeyMap)
- condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
-
- testCases := []struct {
- key string
- expectedResult string
- }{
- // Remove non-existent key.
- {"s3:myprefix", `{"s3:prefix":["hello","world"]}`},
- // Remove existing key.
- {"s3:prefix", `{}`},
- }
-
- for _, testCase := range testCases {
- condKeyMap.RemoveKey(testCase.key)
- if data, err := json.Marshal(condKeyMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// CopyConditionKeyMap() is called and the result is validated.
-func TestCopyConditionKeyMap(t *testing.T) {
- emptyCondKeyMap := make(ConditionKeyMap)
- nonEmptyCondKeyMap := make(ConditionKeyMap)
- nonEmptyCondKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
-
- testCases := []struct {
- condKeyMap ConditionKeyMap
- expectedResult string
- }{
- // To test empty ConditionKeyMap.
- {emptyCondKeyMap, `{}`},
- // To test non-empty ConditionKeyMap.
- {nonEmptyCondKeyMap, `{"s3:prefix":["hello","world"]}`},
- }
-
- for _, testCase := range testCases {
- condKeyMap := CopyConditionKeyMap(testCase.condKeyMap)
- if data, err := json.Marshal(condKeyMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// mergeConditionKeyMap() is called and the result is validated.
-func TestMergeConditionKeyMap(t *testing.T) {
- condKeyMap1 := make(ConditionKeyMap)
- condKeyMap1.Add("s3:prefix", set.CreateStringSet("hello"))
-
- condKeyMap2 := make(ConditionKeyMap)
- condKeyMap2.Add("s3:prefix", set.CreateStringSet("world"))
-
- condKeyMap3 := make(ConditionKeyMap)
- condKeyMap3.Add("s3:myprefix", set.CreateStringSet("world"))
-
- testCases := []struct {
- condKeyMap1 ConditionKeyMap
- condKeyMap2 ConditionKeyMap
- expectedResult string
- }{
- // Both arguments are empty.
- {make(ConditionKeyMap), make(ConditionKeyMap), `{}`},
- // First argument is empty.
- {make(ConditionKeyMap), condKeyMap1, `{"s3:prefix":["hello"]}`},
- // Second argument is empty.
- {condKeyMap1, make(ConditionKeyMap), `{"s3:prefix":["hello"]}`},
- // Both arguments are same value.
- {condKeyMap1, condKeyMap1, `{"s3:prefix":["hello"]}`},
- // Value of second argument will be merged.
- {condKeyMap1, condKeyMap2, `{"s3:prefix":["hello","world"]}`},
- // second argument will be added.
- {condKeyMap1, condKeyMap3, `{"s3:myprefix":["world"],"s3:prefix":["hello"]}`},
- }
-
- for _, testCase := range testCases {
- condKeyMap := mergeConditionKeyMap(testCase.condKeyMap1, testCase.condKeyMap2)
- if data, err := json.Marshal(condKeyMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// ConditionMap.Add() is called and the result is validated.
-func TestConditionMapAdd(t *testing.T) {
- condMap := make(ConditionMap)
-
- condKeyMap1 := make(ConditionKeyMap)
- condKeyMap1.Add("s3:prefix", set.CreateStringSet("hello"))
-
- condKeyMap2 := make(ConditionKeyMap)
- condKeyMap2.Add("s3:prefix", set.CreateStringSet("hello", "world"))
-
- testCases := []struct {
- key string
- value ConditionKeyMap
- expectedResult string
- }{
- // Add new key and value.
- {"StringEquals", condKeyMap1, `{"StringEquals":{"s3:prefix":["hello"]}}`},
- // Add existing key and value.
- {"StringEquals", condKeyMap1, `{"StringEquals":{"s3:prefix":["hello"]}}`},
- // Add existing key and not value.
- {"StringEquals", condKeyMap2, `{"StringEquals":{"s3:prefix":["hello","world"]}}`},
- }
-
- for _, testCase := range testCases {
- condMap.Add(testCase.key, testCase.value)
- if data, err := json.Marshal(condMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// ConditionMap.Remove() is called and the result is validated.
-func TestConditionMapRemove(t *testing.T) {
- condMap := make(ConditionMap)
- condKeyMap := make(ConditionKeyMap)
- condKeyMap.Add("s3:prefix", set.CreateStringSet("hello", "world"))
- condMap.Add("StringEquals", condKeyMap)
-
- testCases := []struct {
- key string
- expectedResult string
- }{
- // Remove non-existent key.
- {"StringNotEquals", `{"StringEquals":{"s3:prefix":["hello","world"]}}`},
- // Remove existing key.
- {"StringEquals", `{}`},
- }
-
- for _, testCase := range testCases {
- condMap.Remove(testCase.key)
- if data, err := json.Marshal(condMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// mergeConditionMap() is called and the result is validated.
-func TestMergeConditionMap(t *testing.T) {
- condKeyMap1 := make(ConditionKeyMap)
- condKeyMap1.Add("s3:prefix", set.CreateStringSet("hello"))
- condMap1 := make(ConditionMap)
- condMap1.Add("StringEquals", condKeyMap1)
-
- condKeyMap2 := make(ConditionKeyMap)
- condKeyMap2.Add("s3:prefix", set.CreateStringSet("world"))
- condMap2 := make(ConditionMap)
- condMap2.Add("StringEquals", condKeyMap2)
-
- condMap3 := make(ConditionMap)
- condMap3.Add("StringNotEquals", condKeyMap2)
-
- testCases := []struct {
- condMap1 ConditionMap
- condMap2 ConditionMap
- expectedResult string
- }{
- // Both arguments are empty.
- {make(ConditionMap), make(ConditionMap), `{}`},
- // First argument is empty.
- {make(ConditionMap), condMap1, `{"StringEquals":{"s3:prefix":["hello"]}}`},
- // Second argument is empty.
- {condMap1, make(ConditionMap), `{"StringEquals":{"s3:prefix":["hello"]}}`},
- // Both arguments are same value.
- {condMap1, condMap1, `{"StringEquals":{"s3:prefix":["hello"]}}`},
- // Value of second argument will be merged.
- {condMap1, condMap2, `{"StringEquals":{"s3:prefix":["hello","world"]}}`},
- // second argument will be added.
- {condMap1, condMap3, `{"StringEquals":{"s3:prefix":["hello"]},"StringNotEquals":{"s3:prefix":["world"]}}`},
- }
-
- for _, testCase := range testCases {
- condMap := mergeConditionMap(testCase.condMap1, testCase.condMap2)
- if data, err := json.Marshal(condMap); err != nil {
- t.Fatalf("Unable to marshal ConditionKeyMap to JSON, %s", err)
- } else {
- if string(data) != testCase.expectedResult {
- t.Fatalf("case: %+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy_test.go b/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy_test.go
deleted file mode 100644
index 1e5196f7c..000000000
--- a/vendor/github.com/minio/minio-go/pkg/policy/bucket-policy_test.go
+++ /dev/null
@@ -1,1823 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 policy
-
-import (
- "encoding/json"
- "fmt"
- "reflect"
- "testing"
-
- "github.com/minio/minio-go/pkg/set"
-)
-
-// isValidStatement() is called and the result is validated.
-func TestIsValidStatement(t *testing.T) {
- testCases := []struct {
- statement Statement
- bucketName string
- expectedResult bool
- }{
- // Empty statement and bucket name.
- {Statement{}, "", false},
- // Empty statement.
- {Statement{}, "mybucket", false},
- // Empty bucket name.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false},
- // Statement with unknown actions.
- {Statement{
- Actions: set.CreateStringSet("s3:ListBucketVersions"),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "mybucket", false},
- // Statement with unknown effect.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "mybucket", false},
- // Statement with nil Principal.AWS.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "mybucket", false},
- // Statement with unknown Principal.AWS.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "mybucket", false},
- // Statement with different bucket name.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }, "mybucket", false},
- // Statement with bucket name with suffixed string.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybuckettest/myobject"),
- }, "mybucket", false},
- // Statement with bucket name and object name.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/myobject"),
- }, "mybucket", true},
- // Statement with condition, bucket name and object name.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/myobject"),
- }, "mybucket", true},
- }
-
- for _, testCase := range testCases {
- if result := isValidStatement(testCase.statement, testCase.bucketName); result != testCase.expectedResult {
- t.Fatalf("%+v: expected: %t, got: %t", testCase, testCase.expectedResult, result)
- }
- }
-}
-
-// newStatements() is called and the result is validated.
-func TestNewStatements(t *testing.T) {
- testCases := []struct {
- policy BucketPolicy
- bucketName string
- prefix string
- expectedResult string
- }{
- // BucketPolicyNone: with empty bucket name and prefix.
- {BucketPolicyNone, "", "", `[]`},
- // BucketPolicyNone: with bucket name and empty prefix.
- {BucketPolicyNone, "mybucket", "", `[]`},
- // BucketPolicyNone: with empty bucket name empty prefix.
- {BucketPolicyNone, "", "hello", `[]`},
- // BucketPolicyNone: with bucket name prefix.
- {BucketPolicyNone, "mybucket", "hello", `[]`},
- // BucketPolicyReadOnly: with empty bucket name and prefix.
- {BucketPolicyReadOnly, "", "", `[]`},
- // BucketPolicyReadOnly: with bucket name and empty prefix.
- {BucketPolicyReadOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyReadOnly: with empty bucket name empty prefix.
- {BucketPolicyReadOnly, "", "hello", `[]`},
- // BucketPolicyReadOnly: with bucket name prefix.
- {BucketPolicyReadOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // BucketPolicyReadWrite: with empty bucket name and prefix.
- {BucketPolicyReadWrite, "", "", `[]`},
- // BucketPolicyReadWrite: with bucket name and empty prefix.
- {BucketPolicyReadWrite, "mybucket", "", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyReadWrite: with empty bucket name empty prefix.
- {BucketPolicyReadWrite, "", "hello", `[]`},
- // BucketPolicyReadWrite: with bucket name prefix.
- {BucketPolicyReadWrite, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // BucketPolicyWriteOnly: with empty bucket name and prefix.
- {BucketPolicyWriteOnly, "", "", `[]`},
- // BucketPolicyWriteOnly: with bucket name and empty prefix.
- {BucketPolicyWriteOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyWriteOnly: with empty bucket name empty prefix.
- {BucketPolicyWriteOnly, "", "hello", `[]`},
- // BucketPolicyWriteOnly: with bucket name prefix.
- {BucketPolicyWriteOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- }
-
- for _, testCase := range testCases {
- statements := newStatements(testCase.policy, testCase.bucketName, testCase.prefix)
- if data, err := json.Marshal(statements); err == nil {
- if string(data) != testCase.expectedResult {
- t.Fatalf("%+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
- }
-}
-
-// getInUsePolicy() is called and the result is validated.
-func TestGetInUsePolicy(t *testing.T) {
- testCases := []struct {
- statements []Statement
- bucketName string
- prefix string
- expectedResult1 bool
- expectedResult2 bool
- }{
- // All empty statements, bucket name and prefix.
- {[]Statement{}, "", "", false, false},
- // Non-empty statements, empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "", false, false},
- // Non-empty statements, non-empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", false, false},
- // Non-empty statements, empty bucket name and non-empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "hello", false, false},
- // Empty statements, non-empty bucket name and empty prefix.
- {[]Statement{}, "mybucket", "", false, false},
- // Empty statements, non-empty bucket name non-empty prefix.
- {[]Statement{}, "mybucket", "hello", false, false},
- // Empty statements, empty bucket name and non-empty prefix.
- {[]Statement{}, "", "hello", false, false},
- // Non-empty statements, non-empty bucket name, non-empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", false, false},
- // different bucket statements and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "", false, false},
- // different bucket statements.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "hello", false, false},
- // different bucket multi-statements and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }, {
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket/world"),
- }}, "mybucket", "", false, false},
- // different bucket multi-statements.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }, {
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket/world"),
- }}, "mybucket", "hello", false, false},
- // read-only in use.
- {[]Statement{{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", true, false},
- // write-only in use.
- {[]Statement{{
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", false, true},
- // read-write in use.
- {[]Statement{{
- Actions: readWriteObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", true, true},
- // read-write multi-statements.
- {[]Statement{{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/ground"),
- }}, "mybucket", "hello", true, true},
- }
-
- for _, testCase := range testCases {
- result1, result2 := getInUsePolicy(testCase.statements, testCase.bucketName, testCase.prefix)
- if !(result1 == testCase.expectedResult1 && result2 == testCase.expectedResult2) {
- t.Fatalf("%+v: expected: [%t,%t], got: [%t,%t]", testCase,
- testCase.expectedResult1, testCase.expectedResult2,
- result1, result2)
- }
- }
-}
-
-// removeStatements() is called and the result is validated.
-func TestRemoveStatements(t *testing.T) {
- unknownCondMap1 := make(ConditionMap)
- unknownCondKeyMap1 := make(ConditionKeyMap)
- unknownCondKeyMap1.Add("s3:prefix", set.CreateStringSet("hello"))
- unknownCondMap1.Add("StringNotEquals", unknownCondKeyMap1)
-
- unknownCondMap11 := make(ConditionMap)
- unknownCondKeyMap11 := make(ConditionKeyMap)
- unknownCondKeyMap11.Add("s3:prefix", set.CreateStringSet("hello"))
- unknownCondMap11.Add("StringNotEquals", unknownCondKeyMap11)
-
- unknownCondMap12 := make(ConditionMap)
- unknownCondKeyMap12 := make(ConditionKeyMap)
- unknownCondKeyMap12.Add("s3:prefix", set.CreateStringSet("hello"))
- unknownCondMap12.Add("StringNotEquals", unknownCondKeyMap12)
-
- knownCondMap1 := make(ConditionMap)
- knownCondKeyMap1 := make(ConditionKeyMap)
- knownCondKeyMap1.Add("s3:prefix", set.CreateStringSet("hello"))
- knownCondMap1.Add("StringEquals", knownCondKeyMap1)
-
- knownCondMap11 := make(ConditionMap)
- knownCondKeyMap11 := make(ConditionKeyMap)
- knownCondKeyMap11.Add("s3:prefix", set.CreateStringSet("hello"))
- knownCondMap11.Add("StringEquals", knownCondKeyMap11)
-
- knownCondMap12 := make(ConditionMap)
- knownCondKeyMap12 := make(ConditionKeyMap)
- knownCondKeyMap12.Add("s3:prefix", set.CreateStringSet("hello"))
- knownCondMap12.Add("StringEquals", knownCondKeyMap12)
-
- knownCondMap13 := make(ConditionMap)
- knownCondKeyMap13 := make(ConditionKeyMap)
- knownCondKeyMap13.Add("s3:prefix", set.CreateStringSet("hello"))
- knownCondMap13.Add("StringEquals", knownCondKeyMap13)
-
- knownCondMap14 := make(ConditionMap)
- knownCondKeyMap14 := make(ConditionKeyMap)
- knownCondKeyMap14.Add("s3:prefix", set.CreateStringSet("hello"))
- knownCondMap14.Add("StringEquals", knownCondKeyMap14)
-
- knownCondMap2 := make(ConditionMap)
- knownCondKeyMap2 := make(ConditionKeyMap)
- knownCondKeyMap2.Add("s3:prefix", set.CreateStringSet("hello", "world"))
- knownCondMap2.Add("StringEquals", knownCondKeyMap2)
-
- testCases := []struct {
- statements []Statement
- bucketName string
- prefix string
- expectedResult string
- }{
- // All empty statements, bucket name and prefix.
- {[]Statement{}, "", "", `[]`},
- // Non-empty statements, empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Non-empty statements, non-empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Non-empty statements, empty bucket name and non-empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Empty statements, non-empty bucket name and empty prefix.
- {[]Statement{}, "mybucket", "", `[]`},
- // Empty statements, non-empty bucket name non-empty prefix.
- {[]Statement{}, "mybucket", "hello", `[]`},
- // Empty statements, empty bucket name and non-empty prefix.
- {[]Statement{}, "", "hello", `[]`},
- // Statement with unknown Actions with empty prefix.
- {[]Statement{{
- Actions: set.CreateStringSet("s3:ListBucketVersions", "s3:ListAllMyBuckets"),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListAllMyBuckets","s3:ListBucketVersions"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Actions.
- {[]Statement{{
- Actions: set.CreateStringSet("s3:ListBucketVersions", "s3:ListAllMyBuckets"),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListAllMyBuckets","s3:ListBucketVersions"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Effect with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Deny","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Effect.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Deny","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Principal.User.AWS with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["arn:aws:iam::AccountNumberWithoutHyphens:root"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Principal.User.AWS.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["arn:aws:iam::AccountNumberWithoutHyphens:root"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Principal.User.CanonicalUser with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{CanonicalUser: set.CreateStringSet("649262f44b8145cb")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"CanonicalUser":["649262f44b8145cb"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Principal.User.CanonicalUser.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{CanonicalUser: set.CreateStringSet("649262f44b8145cb")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"CanonicalUser":["649262f44b8145cb"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Conditions with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Conditions.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statement with unknown Resource and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::testbucket"],"Sid":""}]`},
- // Statement with unknown Resource.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::testbucket"],"Sid":""}]`},
- // Statement with known Actions with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[]`},
- // Statement with known Actions.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[]`},
- // Statement with known multiple Actions with empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions).Union(commonBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", `[]`},
- // Statement with known multiple Actions.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions).Union(commonBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", `[]`},
- // RemoveBucketActions with readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readWriteObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readWriteObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with known Conditions, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, known Conditions, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, known Conditions contains other object prefix, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap2,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["world"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with unknown Conditions, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, unknown Conditions, readOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with known Conditions, writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap11,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, known Conditions, writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap11,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with unknown Conditions, writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap11,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, unknown Conditions, writeOnlyInUse.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap11,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with known Conditions, readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap12,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, known Conditions, readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap12,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with unknown Conditions, readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap12,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // RemoveBucketActions with prefix, unknown Conditions, readOnlyInUse and writeOnlyInUse.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap12,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/world"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/world"],"Sid":""}]`},
- // readOnlyObjectActions - RemoveObjectActions with known condition.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // readOnlyObjectActions - RemoveObjectActions with prefix, known condition.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[]`},
- // readOnlyObjectActions - RemoveObjectActions with unknown condition.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // readOnlyObjectActions - RemoveObjectActions with prefix, unknown condition.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // writeOnlyObjectActions - RemoveObjectActions with known condition.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap13,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // writeOnlyObjectActions - RemoveObjectActions with prefix, known condition.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap13,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // writeOnlyObjectActions - RemoveObjectActions with unknown condition.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // writeOnlyObjectActions - RemoveObjectActions with prefix, unknown condition.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // readWriteObjectActions - RemoveObjectActions with known condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap14,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // readWriteObjectActions - RemoveObjectActions with prefix, known condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: knownCondMap13,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[]`},
- // readWriteObjectActions - RemoveObjectActions with unknown condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // readWriteObjectActions - RemoveObjectActions with prefix, unknown condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, {
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }}, "mybucket", "hello", `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringNotEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- }
-
- for _, testCase := range testCases {
- statements := removeStatements(testCase.statements, testCase.bucketName, testCase.prefix)
- if data, err := json.Marshal(statements); err != nil {
- t.Fatalf("unable encoding to json, %s", err)
- } else if string(data) != testCase.expectedResult {
- t.Fatalf("%+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
-}
-
-// appendStatement() is called and the result is validated.
-func TestAppendStatement(t *testing.T) {
- condMap := make(ConditionMap)
- condKeyMap := make(ConditionKeyMap)
- condKeyMap.Add("s3:prefix", set.CreateStringSet("hello"))
- condMap.Add("StringEquals", condKeyMap)
-
- condMap1 := make(ConditionMap)
- condKeyMap1 := make(ConditionKeyMap)
- condKeyMap1.Add("s3:prefix", set.CreateStringSet("world"))
- condMap1.Add("StringEquals", condKeyMap1)
-
- unknownCondMap1 := make(ConditionMap)
- unknownCondKeyMap1 := make(ConditionKeyMap)
- unknownCondKeyMap1.Add("s3:prefix", set.CreateStringSet("world"))
- unknownCondMap1.Add("StringNotEquals", unknownCondKeyMap1)
-
- testCases := []struct {
- statements []Statement
- statement Statement
- expectedResult string
- }{
- // Empty statements and empty new statement.
- {[]Statement{}, Statement{}, `[]`},
- // Non-empty statements and empty new statement.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{}, `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Empty statements and non-empty new statement.
- {[]Statement{}, Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Append existing statement.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Append same statement with different resource.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }, `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""}]`},
- // Append same statement with different actions.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Elements of new statement contains elements in statements.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket", "arn:aws:s3:::testbucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""}]`},
- // Elements of new statement with conditions contains elements in statements.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket", "arn:aws:s3:::testbucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""}]`},
- // Statements with condition and new statement with condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket", "arn:aws:s3:::testbucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["world"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statements with condition and same resources, and new statement with condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello","world"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statements with unknown condition and same resources, and new statement with known condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: unknownCondMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap1,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["world"]},"StringNotEquals":{"s3:prefix":["world"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statements without condition and new statement with condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket", "arn:aws:s3:::testbucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statements with condition and new statement without condition.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: condMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket", "arn:aws:s3:::testbucket"),
- }}, Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, `[{"Action":["s3:ListBucket","s3:ListBucketMultipartUploads"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket","arn:aws:s3:::testbucket"],"Sid":""},{"Action":["s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // Statements and new statement are different.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, Statement{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- }
-
- for _, testCase := range testCases {
- statements := appendStatement(testCase.statements, testCase.statement)
- if data, err := json.Marshal(statements); err != nil {
- t.Fatalf("unable encoding to json, %s", err)
- } else if string(data) != testCase.expectedResult {
- t.Fatalf("%+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
-}
-
-// getBucketPolicy() is called and the result is validated.
-func TestGetBucketPolicy(t *testing.T) {
- helloCondMap := make(ConditionMap)
- helloCondKeyMap := make(ConditionKeyMap)
- helloCondKeyMap.Add("s3:prefix", set.CreateStringSet("hello"))
- helloCondMap.Add("StringEquals", helloCondKeyMap)
-
- worldCondMap := make(ConditionMap)
- worldCondKeyMap := make(ConditionKeyMap)
- worldCondKeyMap.Add("s3:prefix", set.CreateStringSet("world"))
- worldCondMap.Add("StringEquals", worldCondKeyMap)
-
- notHelloCondMap := make(ConditionMap)
- notHelloCondMap.Add("StringNotEquals", worldCondKeyMap)
-
- testCases := []struct {
- statement Statement
- prefix string
- expectedResult1 bool
- expectedResult2 bool
- expectedResult3 bool
- }{
- // Statement with invalid Effect.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with invalid Effect with prefix.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
- // Statement with invalid Principal.AWS.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with invalid Principal.AWS with prefix.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
-
- // Statement with commonBucketActions.
- {Statement{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", true, false, false},
- // Statement with commonBucketActions.
- {Statement{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", true, false, false},
-
- // Statement with commonBucketActions and condition.
- {Statement{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with commonBucketActions and condition.
- {Statement{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
- // Statement with writeOnlyBucketActions.
- {Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, true},
- // Statement with writeOnlyBucketActions.
- {Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, true},
- // Statement with writeOnlyBucketActions and condition
- {Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with writeOnlyBucketActions and condition.
- {Statement{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
- // Statement with readOnlyBucketActions.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, true, false},
- // Statement with readOnlyBucketActions.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, true, false},
- // Statement with readOnlyBucketActions with empty condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with readOnlyBucketActions with empty condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
- // Statement with readOnlyBucketActions with matching condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with readOnlyBucketActions with matching condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, true, false},
-
- // Statement with readOnlyBucketActions with different condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: worldCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with readOnlyBucketActions with different condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: worldCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, false, false},
-
- // Statement with readOnlyBucketActions with StringNotEquals condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: notHelloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "", false, false, false},
- // Statement with readOnlyBucketActions with StringNotEquals condition.
- {Statement{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: notHelloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }, "hello", false, true, false},
- }
-
- for _, testCase := range testCases {
- commonFound, readOnly, writeOnly := getBucketPolicy(testCase.statement, testCase.prefix)
- if !(testCase.expectedResult1 == commonFound && testCase.expectedResult2 == readOnly && testCase.expectedResult3 == writeOnly) {
- t.Fatalf("%+v: expected: [%t,%t,%t], got: [%t,%t,%t]", testCase,
- testCase.expectedResult1, testCase.expectedResult2, testCase.expectedResult3,
- commonFound, readOnly, writeOnly)
- }
- }
-}
-
-// getObjectPolicy() is called and the result is validated.
-func TestGetObjectPolicy(t *testing.T) {
- testCases := []struct {
- statement Statement
- expectedResult1 bool
- expectedResult2 bool
- }{
- // Statement with invalid Effect.
- {Statement{
- Actions: readOnlyObjectActions,
- Effect: "Deny",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, false, false},
- // Statement with invalid Principal.AWS.
- {Statement{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("arn:aws:iam::AccountNumberWithoutHyphens:root")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, false, false},
- // Statement with condition.
- {Statement{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: make(ConditionMap),
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, false, false},
- // Statement with readOnlyObjectActions.
- {Statement{
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, true, false},
- // Statement with writeOnlyObjectActions.
- {Statement{
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, false, true},
- // Statement with readOnlyObjectActions and writeOnlyObjectActions.
- {Statement{
- Actions: readOnlyObjectActions.Union(writeOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/hello*"),
- }, true, true},
- }
-
- for _, testCase := range testCases {
- readOnly, writeOnly := getObjectPolicy(testCase.statement)
- if !(testCase.expectedResult1 == readOnly && testCase.expectedResult2 == writeOnly) {
- t.Fatalf("%+v: expected: [%t,%t], got: [%t,%t]", testCase,
- testCase.expectedResult1, testCase.expectedResult2,
- readOnly, writeOnly)
- }
- }
-}
-
-// GetPolicyRules is called and the result is validated
-func TestListBucketPolicies(t *testing.T) {
-
- // Condition for read objects
- downloadCondMap := make(ConditionMap)
- downloadCondKeyMap := make(ConditionKeyMap)
- downloadCondKeyMap.Add("s3:prefix", set.CreateStringSet("download"))
- downloadCondMap.Add("StringEquals", downloadCondKeyMap)
-
- // Condition for readwrite objects
- downloadUploadCondMap := make(ConditionMap)
- downloadUploadCondKeyMap := make(ConditionKeyMap)
- downloadUploadCondKeyMap.Add("s3:prefix", set.CreateStringSet("both"))
- downloadUploadCondMap.Add("StringEquals", downloadUploadCondKeyMap)
-
- testCases := []struct {
- statements []Statement
- bucketName string
- prefix string
- expectedResult map[string]BucketPolicy
- }{
- // Empty statements, bucket name and prefix.
- {[]Statement{}, "", "", map[string]BucketPolicy{}},
- // Non-empty statements, empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "", map[string]BucketPolicy{}},
- // Empty statements, non-empty bucket name and empty prefix.
- {[]Statement{}, "mybucket", "", map[string]BucketPolicy{}},
- // Readonly object statement
- {[]Statement{
- {
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- },
- {
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: downloadCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- },
- {
- Actions: readOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/download*"),
- }}, "mybucket", "", map[string]BucketPolicy{"mybucket/download*": BucketPolicyReadOnly}},
- // Write Only
- {[]Statement{
- {
- Actions: commonBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- },
- {
- Actions: writeOnlyObjectActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/upload*"),
- }}, "mybucket", "", map[string]BucketPolicy{"mybucket/upload*": BucketPolicyWriteOnly}},
- // Readwrite
- {[]Statement{
- {
- Actions: commonBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- },
- {
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: downloadUploadCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- },
- {
- Actions: writeOnlyObjectActions.Union(readOnlyObjectActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket/both*"),
- }}, "mybucket", "", map[string]BucketPolicy{"mybucket/both*": BucketPolicyReadWrite}},
- }
-
- for _, testCase := range testCases {
- policyRules := GetPolicies(testCase.statements, testCase.bucketName)
- if !reflect.DeepEqual(testCase.expectedResult, policyRules) {
- t.Fatalf("%+v:\n expected: %+v, got: %+v", testCase, testCase.expectedResult, policyRules)
- }
- }
-}
-
-// GetPolicy() is called and the result is validated.
-func TestGetPolicy(t *testing.T) {
- helloCondMap := make(ConditionMap)
- helloCondKeyMap := make(ConditionKeyMap)
- helloCondKeyMap.Add("s3:prefix", set.CreateStringSet("hello"))
- helloCondMap.Add("StringEquals", helloCondKeyMap)
-
- testCases := []struct {
- statements []Statement
- bucketName string
- prefix string
- expectedResult BucketPolicy
- }{
- // Empty statements, bucket name and prefix.
- {[]Statement{}, "", "", BucketPolicyNone},
- // Non-empty statements, empty bucket name and empty prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "", "", BucketPolicyNone},
- // Empty statements, non-empty bucket name and empty prefix.
- {[]Statement{}, "mybucket", "", BucketPolicyNone},
- // not-matching Statements.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // not-matching Statements with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only commonBucketActions.
- {[]Statement{{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only commonBucketActions with prefix.
- {[]Statement{{
- Actions: commonBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only readOnlyBucketActions.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only readOnlyBucketActions with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only readOnlyBucketActions with conditions.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only readOnlyBucketActions with prefix with conditons.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only writeOnlyBucketActions.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only writeOnlyBucketActions with prefix.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only readOnlyBucketActions + writeOnlyBucketActions.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only readOnlyBucketActions + writeOnlyBucketActions with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- // Statements with only readOnlyBucketActions + writeOnlyBucketActions and conditions.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "", BucketPolicyNone},
- // Statements with only readOnlyBucketActions + writeOnlyBucketActions and conditions with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions.Union(writeOnlyBucketActions),
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, "mybucket", "hello", BucketPolicyNone},
- }
-
- for _, testCase := range testCases {
- policy := GetPolicy(testCase.statements, testCase.bucketName, testCase.prefix)
- if testCase.expectedResult != policy {
- t.Fatalf("%+v: expected: %s, got: %s", testCase, testCase.expectedResult, policy)
- }
- }
-}
-
-// SetPolicy() is called and the result is validated.
-func TestSetPolicy(t *testing.T) {
- helloCondMap := make(ConditionMap)
- helloCondKeyMap := make(ConditionKeyMap)
- helloCondKeyMap.Add("s3:prefix", set.CreateStringSet("hello"))
- helloCondMap.Add("StringEquals", helloCondKeyMap)
-
- testCases := []struct {
- statements []Statement
- policy BucketPolicy
- bucketName string
- prefix string
- expectedResult string
- }{
- // BucketPolicyNone - empty statements, bucket name and prefix.
- {[]Statement{}, BucketPolicyNone, "", "", `[]`},
- // BucketPolicyNone - non-empty statements, bucket name and prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyNone, "", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""}]`},
- // BucketPolicyNone - empty statements, non-empty bucket name and prefix.
- {[]Statement{}, BucketPolicyNone, "mybucket", "", `[]`},
- // BucketPolicyNone - empty statements, bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyNone, "", "hello", `[]`},
- // BucketPolicyReadOnly - empty statements, bucket name and prefix.
- {[]Statement{}, BucketPolicyReadOnly, "", "", `[]`},
- // BucketPolicyReadOnly - non-empty statements, bucket name and prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, BucketPolicyReadOnly, "", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::testbucket"],"Sid":""}]`},
- // BucketPolicyReadOnly - empty statements, non-empty bucket name and prefix.
- {[]Statement{}, BucketPolicyReadOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyReadOnly - empty statements, bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyReadOnly, "", "hello", `[]`},
- // BucketPolicyReadOnly - empty statements, non-empty bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyReadOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // BucketPolicyWriteOnly - empty statements, bucket name and prefix.
- {[]Statement{}, BucketPolicyReadOnly, "", "", `[]`},
- // BucketPolicyWriteOnly - non-empty statements, bucket name and prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, BucketPolicyWriteOnly, "", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::testbucket"],"Sid":""}]`},
- // BucketPolicyWriteOnly - empty statements, non-empty bucket name and prefix.
- {[]Statement{}, BucketPolicyWriteOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyWriteOnly - empty statements, bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyWriteOnly, "", "hello", `[]`},
- // BucketPolicyWriteOnly - empty statements, non-empty bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyWriteOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // BucketPolicyReadWrite - empty statements, bucket name and prefix.
- {[]Statement{}, BucketPolicyReadWrite, "", "", `[]`},
- // BucketPolicyReadWrite - non-empty statements, bucket name and prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::testbucket"),
- }}, BucketPolicyReadWrite, "", "", `[{"Action":["s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::testbucket"],"Sid":""}]`},
- // BucketPolicyReadWrite - empty statements, non-empty bucket name and prefix.
- {[]Statement{}, BucketPolicyReadWrite, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // BucketPolicyReadWrite - empty statements, bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyReadWrite, "", "hello", `[]`},
- // BucketPolicyReadWrite - empty statements, non-empty bucket name and non-empty prefix.
- {[]Statement{}, BucketPolicyReadWrite, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // Set readonly.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyReadOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucket"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // Set readonly with prefix.
- {[]Statement{{
- Actions: writeOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyReadOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:GetObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- // Set writeonly.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyWriteOnly, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // Set writeonly with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyWriteOnly, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
-
- // Set readwrite.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyReadWrite, "mybucket", "", `[{"Action":["s3:GetBucketLocation","s3:ListBucket","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/*"],"Sid":""}]`},
- // Set readwrite with prefix.
- {[]Statement{{
- Actions: readOnlyBucketActions,
- Effect: "Allow",
- Principal: User{AWS: set.CreateStringSet("*")},
- Conditions: helloCondMap,
- Resources: set.CreateStringSet("arn:aws:s3:::mybucket"),
- }}, BucketPolicyReadWrite, "mybucket", "hello", `[{"Action":["s3:GetBucketLocation","s3:ListBucketMultipartUploads"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:ListBucket"],"Condition":{"StringEquals":{"s3:prefix":["hello"]}},"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket"],"Sid":""},{"Action":["s3:AbortMultipartUpload","s3:DeleteObject","s3:GetObject","s3:ListMultipartUploadParts","s3:PutObject"],"Effect":"Allow","Principal":{"AWS":["*"]},"Resource":["arn:aws:s3:::mybucket/hello*"],"Sid":""}]`},
- }
-
- for _, testCase := range testCases {
- statements := SetPolicy(testCase.statements, testCase.policy, testCase.bucketName, testCase.prefix)
- if data, err := json.Marshal(statements); err != nil {
- t.Fatalf("unable encoding to json, %s", err)
- } else if string(data) != testCase.expectedResult {
- t.Fatalf("%+v: expected: %s, got: %s", testCase, testCase.expectedResult, string(data))
- }
- }
-}
-
-// Validates bucket policy string.
-func TestIsValidBucketPolicy(t *testing.T) {
- testCases := []struct {
- inputPolicy BucketPolicy
- expectedResult bool
- }{
- // valid inputs.
- {BucketPolicy("none"), true},
- {BucketPolicy("readonly"), true},
- {BucketPolicy("readwrite"), true},
- {BucketPolicy("writeonly"), true},
- // invalid input.
- {BucketPolicy("readwriteonly"), false},
- {BucketPolicy("writeread"), false},
- }
-
- for i, testCase := range testCases {
- actualResult := testCase.inputPolicy.IsValidBucketPolicy()
- if testCase.expectedResult != actualResult {
- t.Errorf("Test %d: Expected IsValidBucket policy to be '%v' for policy \"%s\", but instead found it to be '%v'", i+1, testCase.expectedResult, testCase.inputPolicy, actualResult)
- }
- }
-}
-
-// Tests validate Bucket policy resource matcher.
-func TestBucketPolicyResourceMatch(t *testing.T) {
-
- // generates\ statement with given resource..
- generateStatement := func(resource string) Statement {
- statement := Statement{}
- statement.Resources = set.CreateStringSet(resource)
- return statement
- }
-
- // generates resource prefix.
- generateResource := func(bucketName, objectName string) string {
- return awsResourcePrefix + bucketName + "/" + objectName
- }
-
- testCases := []struct {
- resourceToMatch string
- statement Statement
- expectedResourceMatch bool
- }{
- // Test case 1-4.
- // Policy with resource ending with bucket/* allows access to all objects inside the given bucket.
- {generateResource("minio-bucket", ""), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/*")), true},
- {generateResource("minio-bucket", ""), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/*")), true},
- {generateResource("minio-bucket", ""), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/*")), true},
- {generateResource("minio-bucket", ""), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/*")), true},
- // Test case - 5.
- // Policy with resource ending with bucket/oo* should not allow access to bucket/output.txt.
- {generateResource("minio-bucket", "output.txt"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/oo*")), false},
- // Test case - 6.
- // Policy with resource ending with bucket/oo* should allow access to bucket/ootput.txt.
- {generateResource("minio-bucket", "ootput.txt"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/oo*")), true},
- // Test case - 7.
- // Policy with resource ending with bucket/oo* allows access to all subfolders starting with "oo" inside given bucket.
- {generateResource("minio-bucket", "oop-bucket/my-file"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/oo*")), true},
- // Test case - 8.
- {generateResource("minio-bucket", "Asia/India/1.pjg"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/Asia/Japan/*")), false},
- // Test case - 9.
- {generateResource("minio-bucket", "Asia/India/1.pjg"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix, "minio-bucket"+"/Asia/Japan/*")), false},
- // Test case - 10.
- // Proves that the name space is flat.
- {generateResource("minio-bucket", "Africa/Bihar/India/design_info.doc/Bihar"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix,
- "minio-bucket"+"/*/India/*/Bihar")), true},
- // Test case - 11.
- // Proves that the name space is flat.
- {generateResource("minio-bucket", "Asia/China/India/States/Bihar/output.txt"), generateStatement(fmt.Sprintf("%s%s", awsResourcePrefix,
- "minio-bucket"+"/*/India/*/Bihar/*")), true},
- }
- for i, testCase := range testCases {
- resources := testCase.statement.Resources.FuncMatch(resourceMatch, testCase.resourceToMatch)
- actualResourceMatch := resources.Equals(testCase.statement.Resources)
- if testCase.expectedResourceMatch != actualResourceMatch {
- t.Errorf("Test %d: Expected Resource match to be `%v`, but instead found it to be `%v`", i+1, testCase.expectedResourceMatch, actualResourceMatch)
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go
deleted file mode 100644
index 297ab97be..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 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 s3signer
-
-import (
- "bytes"
- "io/ioutil"
- "testing"
- "time"
-)
-
-func TestGetSeedSignature(t *testing.T) {
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- dataLen := 66560
- data := bytes.Repeat([]byte("a"), dataLen)
- body := ioutil.NopCloser(bytes.NewReader(data))
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", body)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.Host = "s3.amazonaws.com"
-
- reqTime, err := time.Parse("20060102T150405Z", "20130524T000000Z")
- if err != nil {
- t.Fatalf("Failed to parse time - %v", err)
- }
-
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", "us-east-1", int64(dataLen), reqTime)
- actualSeedSignature := req.Body.(*StreamingReader).seedSignature
-
- expectedSeedSignature := "38cab3af09aa15ddf29e26e36236f60fb6bfb6243a20797ae9a8183674526079"
- if actualSeedSignature != expectedSeedSignature {
- t.Errorf("Expected %s but received %s", expectedSeedSignature, actualSeedSignature)
- }
-}
-
-func TestChunkSignature(t *testing.T) {
- chunkData := bytes.Repeat([]byte("a"), 65536)
- reqTime, _ := time.Parse(iso8601DateFormat, "20130524T000000Z")
- previousSignature := "4f232c4386841ef735655705268965c44a0e4690baa4adea153f7db9fa80a0a9"
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- expectedSignature := "ad80c730a21e5b8d04586a2213dd63b9a0e99e0e2307b0ade35a65485a288648"
- actualSignature := buildChunkSignature(chunkData, reqTime, location, previousSignature, secretAccessKeyID)
- if actualSignature != expectedSignature {
- t.Errorf("Expected %s but received %s", expectedSignature, actualSignature)
- }
-}
-
-func TestSetStreamingAuthorization(t *testing.T) {
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", nil)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.Host = ""
- req.URL.Host = "s3.amazonaws.com"
-
- dataLen := int64(65 * 1024)
- reqTime, _ := time.Parse(iso8601DateFormat, "20130524T000000Z")
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", location, dataLen, reqTime)
-
- expectedAuthorization := "AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-decoded-content-length;x-amz-storage-class,Signature=38cab3af09aa15ddf29e26e36236f60fb6bfb6243a20797ae9a8183674526079"
-
- actualAuthorization := req.Header.Get("Authorization")
- if actualAuthorization != expectedAuthorization {
- t.Errorf("Expected %s but received %s", expectedAuthorization, actualAuthorization)
- }
-}
-
-func TestStreamingReader(t *testing.T) {
- reqTime, _ := time.Parse("20060102T150405Z", "20130524T000000Z")
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
- dataLen := int64(65 * 1024)
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", nil)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.ContentLength = 65 * 1024
- req.Host = ""
- req.URL.Host = "s3.amazonaws.com"
-
- baseReader := ioutil.NopCloser(bytes.NewReader(bytes.Repeat([]byte("a"), 65*1024)))
- req.Body = baseReader
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", location, dataLen, reqTime)
-
- b, err := ioutil.ReadAll(req.Body)
- if err != nil {
- t.Errorf("Expected no error but received %v %d", err, len(b))
- }
- req.Body.Close()
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go
deleted file mode 100644
index 042b6e65c..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3signer
-
-import (
- "sort"
- "testing"
-)
-
-// Tests for 'func TestResourceListSorting(t *testing.T)'.
-func TestResourceListSorting(t *testing.T) {
- sortedResourceList := make([]string, len(resourceList))
- copy(sortedResourceList, resourceList)
- sort.Strings(sortedResourceList)
- for i := 0; i < len(resourceList); i++ {
- if resourceList[i] != sortedResourceList[i] {
- t.Errorf("Expected resourceList[%d] = \"%s\", resourceList is not correctly sorted.", i, sortedResourceList[i])
- break
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go
deleted file mode 100644
index a109a4f2a..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3signer
-
-import (
- "io"
- "net/http"
- "strings"
- "testing"
-)
-
-func TestRequestHost(t *testing.T) {
- req, _ := buildRequest("dynamodb", "us-east-1", "{}")
- req.URL.RawQuery = "Foo=z&Foo=o&Foo=m&Foo=a"
- req.Host = "myhost"
- canonicalHeaders := getCanonicalHeaders(*req, v4IgnoredHeaders)
-
- if !strings.Contains(canonicalHeaders, "host:"+req.Host) {
- t.Errorf("canonical host header invalid")
- }
-}
-
-func buildRequest(serviceName, region, body string) (*http.Request, io.ReadSeeker) {
- endpoint := "https://" + serviceName + "." + region + ".amazonaws.com"
- reader := strings.NewReader(body)
- req, _ := http.NewRequest("POST", endpoint, reader)
- req.URL.Opaque = "//example.org/bucket/key-._~,!@#$%^&*()"
- req.Header.Add("X-Amz-Target", "prefix.Operation")
- req.Header.Add("Content-Type", "application/x-amz-json-1.0")
- req.Header.Add("Content-Length", string(len(body)))
- req.Header.Add("X-Amz-Meta-Other-Header", "some-value=!@#$%^&* (+)")
- req.Header.Add("X-Amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
- req.Header.Add("X-amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
- return req, reader
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go
deleted file mode 100644
index d53483e4e..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3signer
-
-import (
- "net/http"
- "strings"
- "testing"
-)
-
-// Tests signature calculation.
-func TestSignatureCalculation(t *testing.T) {
- req, err := http.NewRequest("GET", "https://s3.amazonaws.com", nil)
- if err != nil {
- t.Fatal("Error:", err)
- }
- req = SignV4(*req, "", "", "", "us-east-1")
- if req.Header.Get("Authorization") != "" {
- t.Fatal("Error: anonymous credentials should not have Authorization header.")
- }
-
- req = PreSignV4(*req, "", "", "", "us-east-1", 0)
- if strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
- t.Fatal("Error: anonymous credentials should not have Signature query resource.")
- }
-
- req = SignV2(*req, "", "")
- if req.Header.Get("Authorization") != "" {
- t.Fatal("Error: anonymous credentials should not have Authorization header.")
- }
-
- req = PreSignV2(*req, "", "", 0)
- if strings.Contains(req.URL.RawQuery, "Signature") {
- t.Fatal("Error: anonymous credentials should not have Signature query resource.")
- }
-
- req = SignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1")
- if req.Header.Get("Authorization") == "" {
- t.Fatal("Error: normal credentials should have Authorization header.")
- }
-
- req = PreSignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1", 0)
- if !strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
- t.Fatal("Error: normal credentials should have Signature query resource.")
- }
-
- req = SignV2(*req, "ACCESS-KEY", "SECRET-KEY")
- if req.Header.Get("Authorization") == "" {
- t.Fatal("Error: normal credentials should have Authorization header.")
- }
-
- req = PreSignV2(*req, "ACCESS-KEY", "SECRET-KEY", 0)
- if !strings.Contains(req.URL.RawQuery, "Signature") {
- t.Fatal("Error: normal credentials should not have Signature query resource.")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go
deleted file mode 100644
index cf96d66c8..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3signer
-
-import (
- "bufio"
- "bytes"
- "crypto/tls"
- "io"
- "io/ioutil"
- "net/http"
- "strings"
-)
-
-// N B minio-go should compile on go1.5.3 onwards and httptest package is
-// available only from go.1.7.x. The following function is taken from
-// Go httptest package to be able to build on older versions of Go.
-
-// NewRequest returns a new incoming server Request, suitable
-// for passing to an http.Handler for testing.
-//
-// The target is the RFC 7230 "request-target": it may be either a
-// path or an absolute URL. If target is an absolute URL, the host name
-// from the URL is used. Otherwise, "example.com" is used.
-//
-// The TLS field is set to a non-nil dummy value if target has scheme
-// "https".
-//
-// The Request.Proto is always HTTP/1.1.
-//
-// An empty method means "GET".
-//
-// The provided body may be nil. If the body is of type *bytes.Reader,
-// *strings.Reader, or *bytes.Buffer, the Request.ContentLength is
-// set.
-//
-// NewRequest panics on error for ease of use in testing, where a
-// panic is acceptable.
-func NewRequest(method, target string, body io.Reader) *http.Request {
- if method == "" {
- method = "GET"
- }
- req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(method + " " + target + " HTTP/1.0\r\n\r\n")))
- if err != nil {
- panic("invalid NewRequest arguments; " + err.Error())
- }
-
- // HTTP/1.0 was used above to avoid needing a Host field. Change it to 1.1 here.
- req.Proto = "HTTP/1.1"
- req.ProtoMinor = 1
- req.Close = false
-
- if body != nil {
- switch v := body.(type) {
- case *bytes.Buffer:
- req.ContentLength = int64(v.Len())
- case *bytes.Reader:
- req.ContentLength = int64(v.Len())
- case *strings.Reader:
- req.ContentLength = int64(v.Len())
- default:
- req.ContentLength = -1
- }
- if rc, ok := body.(io.ReadCloser); ok {
- req.Body = rc
- } else {
- req.Body = ioutil.NopCloser(body)
- }
- }
-
- // 192.0.2.0/24 is "TEST-NET" in RFC 5737 for use solely in
- // documentation and example source code and should not be
- // used publicly.
- req.RemoteAddr = "192.0.2.1:1234"
-
- if req.Host == "" {
- req.Host = "example.com"
- }
-
- if strings.HasPrefix(target, "https://") {
- req.TLS = &tls.ConnectionState{
- Version: tls.VersionTLS12,
- HandshakeComplete: true,
- ServerName: req.Host,
- }
- }
-
- return req
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go
deleted file mode 100644
index 407eddab3..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3signer
-
-import (
- "fmt"
- "net/http"
- "net/url"
- "testing"
-)
-
-// Tests url encoding.
-func TestEncodeURL2Path(t *testing.T) {
- type urlStrings struct {
- bucketName string
- objName string
- encodedObjName string
- }
-
- bucketName := "bucketName"
- want := []urlStrings{
- {
- bucketName: "bucketName",
- objName: "本語",
- encodedObjName: "%E6%9C%AC%E8%AA%9E",
- },
- {
- bucketName: "bucketName",
- objName: "本語.1",
- encodedObjName: "%E6%9C%AC%E8%AA%9E.1",
- },
- {
- objName: ">123>3123123",
- bucketName: "bucketName",
- encodedObjName: "%3E123%3E3123123",
- },
- {
- bucketName: "bucketName",
- objName: "test 1 2.txt",
- encodedObjName: "test%201%202.txt",
- },
- {
- bucketName: "test.bucketName",
- objName: "test++ 1.txt",
- encodedObjName: "test%2B%2B%201.txt",
- },
- }
-
- for _, o := range want {
- u, err := url.Parse(fmt.Sprintf("https://%s.s3.amazonaws.com/%s", bucketName, o.objName))
- if err != nil {
- t.Fatal("Error:", err)
- }
- urlPath := "/" + bucketName + "/" + o.encodedObjName
- if urlPath != encodeURL2Path(&http.Request{URL: u}) {
- t.Fatal("Error")
- }
- }
-
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3utils/utils_test.go b/vendor/github.com/minio/minio-go/pkg/s3utils/utils_test.go
deleted file mode 100644
index 55eaaeacf..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3utils/utils_test.go
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 s3utils
-
-import (
- "errors"
- "net/url"
- "testing"
-)
-
-// Tests get region from host URL.
-func TestGetRegionFromURL(t *testing.T) {
- testCases := []struct {
- u url.URL
- expectedRegion string
- }{
- {
- u: url.URL{Host: "storage.googleapis.com"},
- expectedRegion: "",
- },
- {
- u: url.URL{Host: "s3.cn-north-1.amazonaws.com.cn"},
- expectedRegion: "cn-north-1",
- },
- {
- u: url.URL{Host: "s3.cn-northwest-1.amazonaws.com.cn"},
- expectedRegion: "cn-northwest-1",
- },
- {
- u: url.URL{Host: "s3-fips-us-gov-west-1.amazonaws.com"},
- expectedRegion: "us-gov-west-1",
- },
- {
- u: url.URL{Host: "s3-us-gov-west-1.amazonaws.com"},
- expectedRegion: "us-gov-west-1",
- },
- {
- u: url.URL{Host: "192.168.1.1"},
- expectedRegion: "",
- },
- {
- u: url.URL{Host: "s3-eu-west-1.amazonaws.com"},
- expectedRegion: "eu-west-1",
- },
- {
- u: url.URL{Host: "s3.eu-west-1.amazonaws.com"},
- expectedRegion: "eu-west-1",
- },
- {
- u: url.URL{Host: "s3.dualstack.eu-west-1.amazonaws.com"},
- expectedRegion: "eu-west-1",
- },
- {
- u: url.URL{Host: "s3.amazonaws.com"},
- expectedRegion: "",
- },
- {
- u: url.URL{Host: "s3-external-1.amazonaws.com"},
- expectedRegion: "",
- },
- }
-
- for i, testCase := range testCases {
- region := GetRegionFromURL(testCase.u)
- if testCase.expectedRegion != region {
- t.Errorf("Test %d: Expected region %s, got %s", i+1, testCase.expectedRegion, region)
- }
- }
-}
-
-// Tests for 'isValidDomain(host string) bool'.
-func TestIsValidDomain(t *testing.T) {
- testCases := []struct {
- // Input.
- host string
- // Expected result.
- result bool
- }{
- {"s3.amazonaws.com", true},
- {"s3.cn-north-1.amazonaws.com.cn", true},
- {"s3.cn-northwest-1.amazonaws.com.cn", true},
- {"s3.amazonaws.com_", false},
- {"%$$$", false},
- {"s3.amz.test.com", true},
- {"s3.%%", false},
- {"localhost", true},
- {"-localhost", false},
- {"", false},
- {"\n \t", false},
- {" ", false},
- }
-
- for i, testCase := range testCases {
- result := IsValidDomain(testCase.host)
- if testCase.result != result {
- t.Errorf("Test %d: Expected isValidDomain test to be '%v', but found '%v' instead", i+1, testCase.result, result)
- }
- }
-}
-
-// Tests validate IP address validator.
-func TestIsValidIP(t *testing.T) {
- testCases := []struct {
- // Input.
- ip string
- // Expected result.
- result bool
- }{
- {"192.168.1.1", true},
- {"192.168.1", false},
- {"192.168.1.1.1", false},
- {"-192.168.1.1", false},
- {"260.192.1.1", false},
- }
-
- for i, testCase := range testCases {
- result := IsValidIP(testCase.ip)
- if testCase.result != result {
- t.Errorf("Test %d: Expected isValidIP to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.ip, result)
- }
- }
-
-}
-
-// Tests validate virtual host validator.
-func TestIsVirtualHostSupported(t *testing.T) {
- testCases := []struct {
- url string
- bucket string
- // Expeceted result.
- result bool
- }{
- {"https://s3.amazonaws.com", "my-bucket", true},
- {"https://s3.cn-north-1.amazonaws.com.cn", "my-bucket", true},
- {"https://s3.amazonaws.com", "my-bucket.", false},
- {"https://amazons3.amazonaws.com", "my-bucket.", false},
- {"https://storage.googleapis.com/", "my-bucket", true},
- {"https://mystorage.googleapis.com/", "my-bucket", false},
- }
-
- for i, testCase := range testCases {
- u, err := url.Parse(testCase.url)
- if err != nil {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
- }
- result := IsVirtualHostSupported(*u, testCase.bucket)
- if testCase.result != result {
- t.Errorf("Test %d: Expected isVirtualHostSupported to be '%v' for input url \"%s\" and bucket \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, testCase.bucket, result)
- }
- }
-}
-
-// Tests validate Amazon endpoint validator.
-func TestIsAmazonEndpoint(t *testing.T) {
- testCases := []struct {
- url string
- // Expected result.
- result bool
- }{
- {"https://192.168.1.1", false},
- {"192.168.1.1", false},
- {"http://storage.googleapis.com", false},
- {"https://storage.googleapis.com", false},
- {"storage.googleapis.com", false},
- {"s3.amazonaws.com", false},
- {"https://amazons3.amazonaws.com", false},
- {"-192.168.1.1", false},
- {"260.192.1.1", false},
- {"https://s3-.amazonaws.com", false},
- {"https://s3..amazonaws.com", false},
- {"https://s3.dualstack.us-west-1.amazonaws.com.cn", false},
- {"https://s3..us-west-1.amazonaws.com.cn", false},
- // valid inputs.
- {"https://s3.amazonaws.com", true},
- {"https://s3-external-1.amazonaws.com", true},
- {"https://s3.cn-north-1.amazonaws.com.cn", true},
- {"https://s3-us-west-1.amazonaws.com", true},
- {"https://s3.us-west-1.amazonaws.com", true},
- {"https://s3.dualstack.us-west-1.amazonaws.com", true},
- }
-
- for i, testCase := range testCases {
- u, err := url.Parse(testCase.url)
- if err != nil {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
- }
- result := IsAmazonEndpoint(*u)
- if testCase.result != result {
- t.Errorf("Test %d: Expected isAmazonEndpoint to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, result)
- }
- }
-
-}
-
-// Tests validate Google Cloud end point validator.
-func TestIsGoogleEndpoint(t *testing.T) {
- testCases := []struct {
- url string
- // Expected result.
- result bool
- }{
- {"192.168.1.1", false},
- {"https://192.168.1.1", false},
- {"s3.amazonaws.com", false},
- {"http://s3.amazonaws.com", false},
- {"https://s3.amazonaws.com", false},
- {"https://s3.cn-north-1.amazonaws.com.cn", false},
- {"-192.168.1.1", false},
- {"260.192.1.1", false},
- // valid inputs.
- {"http://storage.googleapis.com", true},
- {"https://storage.googleapis.com", true},
- }
-
- for i, testCase := range testCases {
- u, err := url.Parse(testCase.url)
- if err != nil {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
- }
- result := IsGoogleEndpoint(*u)
- if testCase.result != result {
- t.Errorf("Test %d: Expected isGoogleEndpoint to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, result)
- }
- }
-
-}
-
-func TestPercentEncodeSlash(t *testing.T) {
- testCases := []struct {
- input string
- output string
- }{
- {"test123", "test123"},
- {"abc,+_1", "abc,+_1"},
- {"%40prefix=test%40123", "%40prefix=test%40123"},
- {"key1=val1/val2", "key1=val1%2Fval2"},
- {"%40prefix=test%40123/", "%40prefix=test%40123%2F"},
- }
-
- for i, testCase := range testCases {
- receivedOutput := percentEncodeSlash(testCase.input)
- if testCase.output != receivedOutput {
- t.Errorf(
- "Test %d: Input: \"%s\" --> Expected percentEncodeSlash to return \"%s\", but it returned \"%s\" instead!",
- i+1, testCase.input, testCase.output,
- receivedOutput,
- )
-
- }
- }
-}
-
-// Tests validate the query encoder.
-func TestQueryEncode(t *testing.T) {
- testCases := []struct {
- queryKey string
- valueToEncode []string
- // Expected result.
- result string
- }{
- {"prefix", []string{"test@123", "test@456"}, "prefix=test%40123&prefix=test%40456"},
- {"@prefix", []string{"test@123"}, "%40prefix=test%40123"},
- {"@prefix", []string{"a/b/c/"}, "%40prefix=a%2Fb%2Fc%2F"},
- {"prefix", []string{"test#123"}, "prefix=test%23123"},
- {"prefix#", []string{"test#123"}, "prefix%23=test%23123"},
- {"prefix", []string{"test123"}, "prefix=test123"},
- {"prefix", []string{"test本語123", "test123"}, "prefix=test%E6%9C%AC%E8%AA%9E123&prefix=test123"},
- }
-
- for i, testCase := range testCases {
- urlValues := make(url.Values)
- for _, valueToEncode := range testCase.valueToEncode {
- urlValues.Add(testCase.queryKey, valueToEncode)
- }
- result := QueryEncode(urlValues)
- if testCase.result != result {
- t.Errorf("Test %d: Expected queryEncode result to be \"%s\", but found it to be \"%s\" instead", i+1, testCase.result, result)
- }
- }
-}
-
-// Tests validate the URL path encoder.
-func TestEncodePath(t *testing.T) {
- testCases := []struct {
- // Input.
- inputStr string
- // Expected result.
- result string
- }{
- {"thisisthe%url", "thisisthe%25url"},
- {"本語", "%E6%9C%AC%E8%AA%9E"},
- {"本語.1", "%E6%9C%AC%E8%AA%9E.1"},
- {">123", "%3E123"},
- {"myurl#link", "myurl%23link"},
- {"space in url", "space%20in%20url"},
- {"url+path", "url%2Bpath"},
- }
-
- for i, testCase := range testCases {
- result := EncodePath(testCase.inputStr)
- if testCase.result != result {
- t.Errorf("Test %d: Expected queryEncode result to be \"%s\", but found it to be \"%s\" instead", i+1, testCase.result, result)
- }
- }
-}
-
-// Tests validate the bucket name validator.
-func TestIsValidBucketName(t *testing.T) {
- testCases := []struct {
- // Input.
- bucketName string
- // Expected result.
- err error
- // Flag to indicate whether test should Pass.
- shouldPass bool
- }{
- {".mybucket", errors.New("Bucket name contains invalid characters"), false},
- {"$mybucket", errors.New("Bucket name contains invalid characters"), false},
- {"mybucket-", errors.New("Bucket name contains invalid characters"), false},
- {"my", errors.New("Bucket name cannot be smaller than 3 characters"), false},
- {"", errors.New("Bucket name cannot be empty"), false},
- {"my..bucket", errors.New("Bucket name contains invalid characters"), false},
- {"192.168.1.168", errors.New("Bucket name cannot be an ip address"), false},
- {":bucketname", errors.New("Bucket name contains invalid characters"), false},
- {"_bucketName", errors.New("Bucket name contains invalid characters"), false},
- {"my.bucket.com", nil, true},
- {"my-bucket", nil, true},
- {"123my-bucket", nil, true},
- {"Mybucket", nil, true},
- {"My_bucket", nil, true},
- {"My:bucket", nil, true},
- }
-
- for i, testCase := range testCases {
- err := CheckValidBucketName(testCase.bucketName)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- }
-
-}
-
-// Tests validate the bucket name validator stricter.
-func TestIsValidBucketNameStrict(t *testing.T) {
- testCases := []struct {
- // Input.
- bucketName string
- // Expected result.
- err error
- // Flag to indicate whether test should Pass.
- shouldPass bool
- }{
- {".mybucket", errors.New("Bucket name contains invalid characters"), false},
- {"$mybucket", errors.New("Bucket name contains invalid characters"), false},
- {"mybucket-", errors.New("Bucket name contains invalid characters"), false},
- {"my", errors.New("Bucket name cannot be smaller than 3 characters"), false},
- {"", errors.New("Bucket name cannot be empty"), false},
- {"my..bucket", errors.New("Bucket name contains invalid characters"), false},
- {"192.168.1.168", errors.New("Bucket name cannot be an ip address"), false},
- {"Mybucket", errors.New("Bucket name contains invalid characters"), false},
- {"my.bucket.com", nil, true},
- {"my-bucket", nil, true},
- {"123my-bucket", nil, true},
- }
-
- for i, testCase := range testCases {
- err := CheckValidBucketNameStrict(testCase.bucketName)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- }
-
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go b/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go
deleted file mode 100644
index d7e6aa799..000000000
--- a/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 set
-
-import (
- "fmt"
- "strings"
- "testing"
-)
-
-// NewStringSet() is called and the result is validated.
-func TestNewStringSet(t *testing.T) {
- if ss := NewStringSet(); !ss.IsEmpty() {
- t.Fatalf("expected: true, got: false")
- }
-}
-
-// CreateStringSet() is called and the result is validated.
-func TestCreateStringSet(t *testing.T) {
- ss := CreateStringSet("foo")
- if str := ss.String(); str != `[foo]` {
- t.Fatalf("expected: %s, got: %s", `["foo"]`, str)
- }
-}
-
-// CopyStringSet() is called and the result is validated.
-func TestCopyStringSet(t *testing.T) {
- ss := CreateStringSet("foo")
- sscopy := CopyStringSet(ss)
- if !ss.Equals(sscopy) {
- t.Fatalf("expected: %s, got: %s", ss, sscopy)
- }
-}
-
-// StringSet.Add() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetAdd(t *testing.T) {
- testCases := []struct {
- value string
- expectedResult string
- }{
- // Test first addition.
- {"foo", `[foo]`},
- // Test duplicate addition.
- {"foo", `[foo]`},
- // Test new addition.
- {"bar", `[bar foo]`},
- }
-
- ss := NewStringSet()
- for _, testCase := range testCases {
- ss.Add(testCase.value)
- if str := ss.String(); str != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
- }
- }
-}
-
-// StringSet.Remove() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetRemove(t *testing.T) {
- ss := CreateStringSet("foo", "bar")
- testCases := []struct {
- value string
- expectedResult string
- }{
- // Test removing non-existen item.
- {"baz", `[bar foo]`},
- // Test remove existing item.
- {"foo", `[bar]`},
- // Test remove existing item again.
- {"foo", `[bar]`},
- // Test remove to make set to empty.
- {"bar", `[]`},
- }
-
- for _, testCase := range testCases {
- ss.Remove(testCase.value)
- if str := ss.String(); str != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
- }
- }
-}
-
-// StringSet.Contains() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetContains(t *testing.T) {
- ss := CreateStringSet("foo")
- testCases := []struct {
- value string
- expectedResult bool
- }{
- // Test to check non-existent item.
- {"bar", false},
- // Test to check existent item.
- {"foo", true},
- // Test to verify case sensitivity.
- {"Foo", false},
- }
-
- for _, testCase := range testCases {
- if result := ss.Contains(testCase.value); result != testCase.expectedResult {
- t.Fatalf("expected: %t, got: %t", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.FuncMatch() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetFuncMatch(t *testing.T) {
- ss := CreateStringSet("foo", "bar")
- testCases := []struct {
- matchFn func(string, string) bool
- value string
- expectedResult string
- }{
- // Test to check match function doing case insensive compare.
- {func(setValue string, compareValue string) bool {
- return strings.ToUpper(setValue) == strings.ToUpper(compareValue)
- }, "Bar", `[bar]`},
- // Test to check match function doing prefix check.
- {func(setValue string, compareValue string) bool {
- return strings.HasPrefix(compareValue, setValue)
- }, "foobar", `[foo]`},
- }
-
- for _, testCase := range testCases {
- s := ss.FuncMatch(testCase.matchFn, testCase.value)
- if result := s.String(); result != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.ApplyFunc() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetApplyFunc(t *testing.T) {
- ss := CreateStringSet("foo", "bar")
- testCases := []struct {
- applyFn func(string) string
- expectedResult string
- }{
- // Test to apply function prepending a known string.
- {func(setValue string) string { return "mybucket/" + setValue }, `[mybucket/bar mybucket/foo]`},
- // Test to apply function modifying values.
- {func(setValue string) string { return setValue[1:] }, `[ar oo]`},
- }
-
- for _, testCase := range testCases {
- s := ss.ApplyFunc(testCase.applyFn)
- if result := s.String(); result != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.Equals() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetEquals(t *testing.T) {
- testCases := []struct {
- set1 StringSet
- set2 StringSet
- expectedResult bool
- }{
- // Test equal set
- {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar"), true},
- // Test second set with more items
- {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar", "baz"), false},
- // Test second set with less items
- {CreateStringSet("foo", "bar"), CreateStringSet("bar"), false},
- }
-
- for _, testCase := range testCases {
- if result := testCase.set1.Equals(testCase.set2); result != testCase.expectedResult {
- t.Fatalf("expected: %t, got: %t", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.Intersection() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetIntersection(t *testing.T) {
- testCases := []struct {
- set1 StringSet
- set2 StringSet
- expectedResult StringSet
- }{
- // Test intersecting all values.
- {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar")},
- // Test intersecting all values in second set.
- {CreateStringSet("foo", "bar", "baz"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar")},
- // Test intersecting different values in second set.
- {CreateStringSet("foo", "baz"), CreateStringSet("baz", "bar"), CreateStringSet("baz")},
- // Test intersecting none.
- {CreateStringSet("foo", "baz"), CreateStringSet("poo", "bar"), NewStringSet()},
- }
-
- for _, testCase := range testCases {
- if result := testCase.set1.Intersection(testCase.set2); !result.Equals(testCase.expectedResult) {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.Difference() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetDifference(t *testing.T) {
- testCases := []struct {
- set1 StringSet
- set2 StringSet
- expectedResult StringSet
- }{
- // Test differing none.
- {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar"), NewStringSet()},
- // Test differing in first set.
- {CreateStringSet("foo", "bar", "baz"), CreateStringSet("foo", "bar"), CreateStringSet("baz")},
- // Test differing values in both set.
- {CreateStringSet("foo", "baz"), CreateStringSet("baz", "bar"), CreateStringSet("foo")},
- // Test differing all values.
- {CreateStringSet("foo", "baz"), CreateStringSet("poo", "bar"), CreateStringSet("foo", "baz")},
- }
-
- for _, testCase := range testCases {
- if result := testCase.set1.Difference(testCase.set2); !result.Equals(testCase.expectedResult) {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.Union() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetUnion(t *testing.T) {
- testCases := []struct {
- set1 StringSet
- set2 StringSet
- expectedResult StringSet
- }{
- // Test union same values.
- {CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar")},
- // Test union same values in second set.
- {CreateStringSet("foo", "bar", "baz"), CreateStringSet("foo", "bar"), CreateStringSet("foo", "bar", "baz")},
- // Test union different values in both set.
- {CreateStringSet("foo", "baz"), CreateStringSet("baz", "bar"), CreateStringSet("foo", "baz", "bar")},
- // Test union all different values.
- {CreateStringSet("foo", "baz"), CreateStringSet("poo", "bar"), CreateStringSet("foo", "baz", "poo", "bar")},
- }
-
- for _, testCase := range testCases {
- if result := testCase.set1.Union(testCase.set2); !result.Equals(testCase.expectedResult) {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetMarshalJSON(t *testing.T) {
- testCases := []struct {
- set StringSet
- expectedResult string
- }{
- // Test set with values.
- {CreateStringSet("foo", "bar"), `["bar","foo"]`},
- // Test empty set.
- {NewStringSet(), "[]"},
- }
-
- for _, testCase := range testCases {
- if result, _ := testCase.set.MarshalJSON(); string(result) != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, string(result))
- }
- }
-}
-
-// StringSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetUnmarshalJSON(t *testing.T) {
- testCases := []struct {
- data []byte
- expectedResult string
- }{
- // Test to convert JSON array to set.
- {[]byte(`["bar","foo"]`), `[bar foo]`},
- // Test to convert JSON string to set.
- {[]byte(`"bar"`), `[bar]`},
- // Test to convert JSON empty array to set.
- {[]byte(`[]`), `[]`},
- // Test to convert JSON empty string to set.
- {[]byte(`""`), `[]`},
- }
-
- for _, testCase := range testCases {
- var set StringSet
- set.UnmarshalJSON(testCase.data)
- if result := set.String(); result != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
- }
- }
-}
-
-// StringSet.String() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetString(t *testing.T) {
- testCases := []struct {
- set StringSet
- expectedResult string
- }{
- // Test empty set.
- {NewStringSet(), `[]`},
- // Test set with empty value.
- {CreateStringSet(""), `[]`},
- // Test set with value.
- {CreateStringSet("foo"), `[foo]`},
- }
-
- for _, testCase := range testCases {
- if str := testCase.set.String(); str != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
- }
- }
-}
-
-// StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.
-func TestStringSetToSlice(t *testing.T) {
- testCases := []struct {
- set StringSet
- expectedResult string
- }{
- // Test empty set.
- {NewStringSet(), `[]`},
- // Test set with empty value.
- {CreateStringSet(""), `[]`},
- // Test set with value.
- {CreateStringSet("foo"), `[foo]`},
- // Test set with value.
- {CreateStringSet("foo", "bar"), `[bar foo]`},
- }
-
- for _, testCase := range testCases {
- sslice := testCase.set.ToSlice()
- if str := fmt.Sprintf("%s", sslice); str != testCase.expectedResult {
- t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/test-utils_test.go b/vendor/github.com/minio/minio-go/test-utils_test.go
deleted file mode 100644
index 6f6443ccf..000000000
--- a/vendor/github.com/minio/minio-go/test-utils_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 minio
-
-import (
- "bytes"
- "encoding/xml"
- "io/ioutil"
- "net/http"
- "strconv"
-)
-
-// Contains common used utilities for tests.
-
-// APIError Used for mocking error response from server.
-type APIError struct {
- Code string
- Description string
- HTTPStatusCode int
-}
-
-// Mocks XML error response from the server.
-func generateErrorResponse(resp *http.Response, APIErr APIError, bucketName string) *http.Response {
- // generate error response.
- errorResponse := getAPIErrorResponse(APIErr, bucketName)
- encodedErrorResponse := encodeResponse(errorResponse)
- // write Header.
- resp.StatusCode = APIErr.HTTPStatusCode
- resp.Body = ioutil.NopCloser(bytes.NewBuffer(encodedErrorResponse))
-
- return resp
-}
-
-// getErrorResponse gets in standard error and resource value and
-// provides a encodable populated response values.
-func getAPIErrorResponse(err APIError, bucketName string) ErrorResponse {
- var errResp = ErrorResponse{}
- errResp.Code = err.Code
- errResp.Message = err.Description
- errResp.BucketName = bucketName
- return errResp
-}
-
-// Encodes the response headers into XML format.
-func encodeResponse(response interface{}) []byte {
- var bytesBuffer bytes.Buffer
- bytesBuffer.WriteString(xml.Header)
- encode := xml.NewEncoder(&bytesBuffer)
- encode.Encode(response)
- return bytesBuffer.Bytes()
-}
-
-// Convert string to bool and always return false if any error
-func mustParseBool(str string) bool {
- b, err := strconv.ParseBool(str)
- if err != nil {
- return false
- }
- return b
-}
diff --git a/vendor/github.com/minio/minio-go/utils_test.go b/vendor/github.com/minio/minio-go/utils_test.go
deleted file mode 100644
index 5411cc91a..000000000
--- a/vendor/github.com/minio/minio-go/utils_test.go
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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 minio
-
-import (
- "fmt"
- "net/http"
- "net/url"
- "testing"
- "time"
-
- "github.com/minio/minio-go/pkg/s3utils"
-)
-
-// Tests signature redacting function used
-// in filtering on-wire Authorization header.
-func TestRedactSignature(t *testing.T) {
- testCases := []struct {
- authValue string
- expectedRedactedAuthValue string
- }{
- {
- authValue: "AWS 1231313:888x000231==",
- expectedRedactedAuthValue: "AWS **REDACTED**:**REDACTED**",
- },
- {
- authValue: "AWS4-HMAC-SHA256 Credential=12312313/20170613/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=02131231312313213",
- expectedRedactedAuthValue: "AWS4-HMAC-SHA256 Credential=**REDACTED**/20170613/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**",
- },
- }
-
- for i, testCase := range testCases {
- redactedAuthValue := redactSignature(testCase.authValue)
- if redactedAuthValue != testCase.expectedRedactedAuthValue {
- t.Errorf("Test %d: Expected %s, got %s", i+1, testCase.expectedRedactedAuthValue, redactedAuthValue)
- }
- }
-}
-
-// Tests filter header function by filtering out
-// some custom header keys.
-func TestFilterHeader(t *testing.T) {
- header := http.Header{}
- header.Set("Content-Type", "binary/octet-stream")
- header.Set("Content-Encoding", "gzip")
- newHeader := filterHeader(header, []string{"Content-Type"})
- if len(newHeader) > 1 {
- t.Fatalf("Unexpected size of the returned header, should be 1, got %d", len(newHeader))
- }
- if newHeader.Get("Content-Encoding") != "gzip" {
- t.Fatalf("Unexpected content-encoding value, expected 'gzip', got %s", newHeader.Get("Content-Encoding"))
- }
-}
-
-// Tests for 'getEndpointURL(endpoint string, inSecure bool)'.
-func TestGetEndpointURL(t *testing.T) {
- testCases := []struct {
- // Inputs.
- endPoint string
- secure bool
-
- // Expected result.
- result string
- err error
- // Flag indicating whether the test is expected to pass or not.
- shouldPass bool
- }{
- {"s3.amazonaws.com", true, "https://s3.amazonaws.com", nil, true},
- {"s3.cn-north-1.amazonaws.com.cn", true, "https://s3.cn-north-1.amazonaws.com.cn", nil, true},
- {"s3.cn-northwest-1.amazonaws.com.cn", true, "https://s3.cn-northwest-1.amazonaws.com.cn", nil, true},
- {"s3.amazonaws.com", false, "http://s3.amazonaws.com", nil, true},
- {"s3.cn-north-1.amazonaws.com.cn", false, "http://s3.cn-north-1.amazonaws.com.cn", nil, true},
- {"s3.cn-northwest-1.amazonaws.com.cn", false, "http://s3.cn-northwest-1.amazonaws.com.cn", nil, true},
- {"192.168.1.1:9000", false, "http://192.168.1.1:9000", nil, true},
- {"192.168.1.1:9000", true, "https://192.168.1.1:9000", nil, true},
- {"s3.amazonaws.com:443", true, "https://s3.amazonaws.com:443", nil, true},
- {"13333.123123.-", true, "", ErrInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "13333.123123.-")), false},
- {"13333.123123.-", true, "", ErrInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "13333.123123.-")), false},
- {"storage.googleapis.com:4000", true, "", ErrInvalidArgument("Google Cloud Storage endpoint should be 'storage.googleapis.com'."), false},
- {"s3.aamzza.-", true, "", ErrInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "s3.aamzza.-")), false},
- {"", true, "", ErrInvalidArgument("Endpoint: does not follow ip address or domain name standards."), false},
- }
-
- for i, testCase := range testCases {
- result, err := getEndpointURL(testCase.endPoint, testCase.secure)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- // Test passes as expected, but the output values are verified for correctness here.
- if err == nil && testCase.shouldPass {
- if testCase.result != result.String() {
- t.Errorf("Test %d: Expected the result Url to be \"%s\", but found \"%s\" instead", i+1, testCase.result, result.String())
- }
- }
- }
-}
-
-// Tests validate end point validator.
-func TestIsValidEndpointURL(t *testing.T) {
- testCases := []struct {
- url string
- err error
- // Flag indicating whether the test is expected to pass or not.
- shouldPass bool
- }{
- {"", ErrInvalidArgument("Endpoint url cannot be empty."), false},
- {"/", nil, true},
- {"https://s3.amazonaws.com", nil, true},
- {"https://s3.cn-north-1.amazonaws.com.cn", nil, true},
- {"https://s3-us-gov-west-1.amazonaws.com", nil, true},
- {"https://s3-fips-us-gov-west-1.amazonaws.com", nil, true},
- {"https://s3.amazonaws.com/", nil, true},
- {"https://storage.googleapis.com/", nil, true},
- {"https://z3.amazonaws.com", nil, true},
- {"https://mybalancer.us-east-1.elb.amazonaws.com", nil, true},
- {"192.168.1.1", ErrInvalidArgument("Endpoint url cannot have fully qualified paths."), false},
- {"https://amazon.googleapis.com/", ErrInvalidArgument("Google Cloud Storage endpoint should be 'storage.googleapis.com'."), false},
- {"https://storage.googleapis.com/bucket/", ErrInvalidArgument("Endpoint url cannot have fully qualified paths."), false},
- {"https://s3.amazonaws.com/bucket/object", ErrInvalidArgument("Endpoint url cannot have fully qualified paths."), false},
- }
-
- for i, testCase := range testCases {
- var u url.URL
- if testCase.url == "" {
- u = sentinelURL
- } else {
- u1, err := url.Parse(testCase.url)
- if err != nil {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
- }
- u = *u1
- }
- err := isValidEndpointURL(u)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err)
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err, err)
- }
- }
-
- }
-}
-
-func TestDefaultBucketLocation(t *testing.T) {
- testCases := []struct {
- endpointURL url.URL
- regionOverride string
- expectedLocation string
- }{
- // Region override is set URL is ignored. - Test 1.
- {
- endpointURL: url.URL{Host: "s3-fips-us-gov-west-1.amazonaws.com"},
- regionOverride: "us-west-1",
- expectedLocation: "us-west-1",
- },
- // No region override, url based preferenced is honored - Test 2.
- {
- endpointURL: url.URL{Host: "s3-fips-us-gov-west-1.amazonaws.com"},
- regionOverride: "",
- expectedLocation: "us-gov-west-1",
- },
- // Region override is honored - Test 3.
- {
- endpointURL: url.URL{Host: "s3.amazonaws.com"},
- regionOverride: "us-west-1",
- expectedLocation: "us-west-1",
- },
- // China region should be honored, region override not provided. - Test 4.
- {
- endpointURL: url.URL{Host: "s3.cn-north-1.amazonaws.com.cn"},
- regionOverride: "",
- expectedLocation: "cn-north-1",
- },
- // China region should be honored, region override not provided. - Test 5.
- {
- endpointURL: url.URL{Host: "s3.cn-northwest-1.amazonaws.com.cn"},
- regionOverride: "",
- expectedLocation: "cn-northwest-1",
- },
- // No region provided, no standard region strings provided as well. - Test 6.
- {
- endpointURL: url.URL{Host: "s3.amazonaws.com"},
- regionOverride: "",
- expectedLocation: "us-east-1",
- },
- }
-
- for i, testCase := range testCases {
- retLocation := getDefaultLocation(testCase.endpointURL, testCase.regionOverride)
- if testCase.expectedLocation != retLocation {
- t.Errorf("Test %d: Expected location %s, got %s", i+1, testCase.expectedLocation, retLocation)
- }
- }
-}
-
-// Tests validate the expiry time validator.
-func TestIsValidExpiry(t *testing.T) {
- testCases := []struct {
- // Input.
- duration time.Duration
- // Expected result.
- err error
- // Flag to indicate whether the test should pass.
- shouldPass bool
- }{
- {100 * time.Millisecond, ErrInvalidArgument("Expires cannot be lesser than 1 second."), false},
- {604801 * time.Second, ErrInvalidArgument("Expires cannot be greater than 7 days."), false},
- {0 * time.Second, ErrInvalidArgument("Expires cannot be lesser than 1 second."), false},
- {1 * time.Second, nil, true},
- {10000 * time.Second, nil, true},
- {999 * time.Second, nil, true},
- }
-
- for i, testCase := range testCases {
- err := isValidExpiry(testCase.duration)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- }
-}
-
-// Tests validate the bucket name validator.
-func TestIsValidBucketName(t *testing.T) {
- testCases := []struct {
- // Input.
- bucketName string
- // Expected result.
- err error
- // Flag to indicate whether test should Pass.
- shouldPass bool
- }{
- {".mybucket", ErrInvalidBucketName("Bucket name contains invalid characters"), false},
- {"mybucket.", ErrInvalidBucketName("Bucket name contains invalid characters"), false},
- {"mybucket-", ErrInvalidBucketName("Bucket name contains invalid characters"), false},
- {"my", ErrInvalidBucketName("Bucket name cannot be smaller than 3 characters"), false},
- {"", ErrInvalidBucketName("Bucket name cannot be empty"), false},
- {"my..bucket", ErrInvalidBucketName("Bucket name contains invalid characters"), false},
- {"my.bucket.com", nil, true},
- {"my-bucket", nil, true},
- {"123my-bucket", nil, true},
- }
-
- for i, testCase := range testCases {
- err := s3utils.CheckValidBucketName(testCase.bucketName)
- if err != nil && testCase.shouldPass {
- t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
- }
- if err == nil && !testCase.shouldPass {
- t.Errorf("Test %d: Expected to fail with <ERROR> \"%s\", but passed instead", i+1, testCase.err.Error())
- }
- // Failed as expected, but does it fail for the expected reason.
- if err != nil && !testCase.shouldPass {
- if err.Error() != testCase.err.Error() {
- t.Errorf("Test %d: Expected to fail with error \"%s\", but instead failed with error \"%s\" instead", i+1, testCase.err.Error(), err.Error())
- }
- }
-
- }
-
-}
-
-// Tests if header is standard supported header
-func TestIsStandardHeader(t *testing.T) {
- testCases := []struct {
- // Input.
- header string
- // Expected result.
- expectedValue bool
- }{
- {"content-encoding", true},
- {"content-type", true},
- {"cache-control", true},
- {"content-disposition", true},
- {"random-header", false},
- }
-
- for i, testCase := range testCases {
- actual := isStandardHeader(testCase.header)
- if actual != testCase.expectedValue {
- t.Errorf("Test %d: Expected to pass, but failed", i+1)
- }
- }
-
-}
-
-// Tests if header is server encryption header
-func TestIsSSEHeader(t *testing.T) {
- testCases := []struct {
- // Input.
- header string
- // Expected result.
- expectedValue bool
- }{
- {"x-amz-server-side-encryption", true},
- {"x-amz-server-side-encryption-aws-kms-key-id", true},
- {"x-amz-server-side-encryption-context", true},
- {"x-amz-server-side-encryption-customer-algorithm", true},
- {"x-amz-server-side-encryption-customer-key", true},
- {"x-amz-server-side-encryption-customer-key-MD5", true},
- {"random-header", false},
- }
-
- for i, testCase := range testCases {
- actual := isSSEHeader(testCase.header)
- if actual != testCase.expectedValue {
- t.Errorf("Test %d: Expected to pass, but failed", i+1)
- }
- }
-}
-
-// Tests if header is client encryption header
-func TestIsCSEHeader(t *testing.T) {
- testCases := []struct {
- // Input.
- header string
- // Expected result.
- expectedValue bool
- }{
- {"x-amz-iv", true},
- {"x-amz-key", true},
- {"x-amz-matdesc", true},
- {"x-amz-meta-x-amz-iv", true},
- {"x-amz-meta-x-amz-key", true},
- {"x-amz-meta-x-amz-matdesc", true},
- {"random-header", false},
- }
-
- for i, testCase := range testCases {
- actual := isCSEHeader(testCase.header)
- if actual != testCase.expectedValue {
- t.Errorf("Test %d: Expected to pass, but failed", i+1)
- }
- }
-
-}
-
-// Tests if header is x-amz-meta or x-amz-acl
-func TestIsAmzHeader(t *testing.T) {
- testCases := []struct {
- // Input.
- header string
- // Expected result.
- expectedValue bool
- }{
- {"x-amz-iv", false},
- {"x-amz-key", false},
- {"x-amz-matdesc", false},
- {"x-amz-meta-x-amz-iv", true},
- {"x-amz-meta-x-amz-key", true},
- {"x-amz-meta-x-amz-matdesc", true},
- {"x-amz-acl", true},
- {"random-header", false},
- }
-
- for i, testCase := range testCases {
- actual := isAmzHeader(testCase.header)
- if actual != testCase.expectedValue {
- t.Errorf("Test %d: Expected to pass, but failed", i+1)
- }
- }
-
-}