vendor: Bring new minio-go changes for bucket policy related bugs (#1746)

This commit is contained in:
Aakash Muttineni
2016-07-04 10:35:15 -07:00
committed by Harshavardhana
parent 67c1957eb0
commit 6f4a0f9cbb
4 changed files with 46 additions and 33 deletions
+1 -1
View File
@@ -433,7 +433,7 @@ __Return Values__
* `objInfo.Size` _int64_: size of the object
* `objInfo.ETag` _string_: etag of the object
* `objInfo.ContentType` _string_: Content-Type of the object
* `objInfo.LastModified` _string_: modified time stamp
* `objInfo.LastModified` _time.Time_: modified time stamp
* `err` _error_
__Example__
+28 -24
View File
@@ -5,7 +5,7 @@ The Minio Golang Client SDK provides simple APIs to access any Amazon S3 compati
- AWS Signature Version 4
- Amazon S3
- Minio
- AWS Signature Version 2
- AWS Signature Version 2
- Google Cloud Storage (Compatibility Mode)
- Openstack Swift + Swift3 middleware
- Ceph Object Gateway
@@ -21,10 +21,18 @@ This document assumes that you have a working [Golang](https://docs.minio.io/doc
```sh
$ go get -u github.com/minio/minio-go
```
## Quick Start Example - File Uploader
This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.
## Initialize Minio Client
You need four items in order to connect to Minio object storage server.
| Params | Description|
| :--- | :--- |
| endpoint | URL to object storage service. |
| accessKeyID | Access key is like user ID that uniquely identifies your account. |
| secretAccessKey | Secret key is the password to your account. |
|secure | Set this value to 'true' to enable secure (HTTPS) access. |
You need four items in order to connect to an object storage server.
```go
package main
@@ -48,12 +56,12 @@ func main() {
}
```
| Params | Description |
| :------- | :------------ |
| endpoint| URL to object storage service. |
| accessKeyID | Access key is like user ID that uniquely identifies your account. |
| secretAccessKey| Secret key is the password to your account.|
|secure|Set this value to 'true' to enable secure (HTTPS) access.|
## Quick Start Example - File Uploader
This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.
We will use the Minio server running at [https://play.minio.io:9000](https://play.minio.io:9000) in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.
#### FileUploader.go
@@ -106,18 +114,6 @@ $ mc ls play/mymusic/
The full API Reference is available here.
* [Complete API Reference](https://docs.minio.io/docs/golang-client-api-reference)
### Object Operations.
* [PutObject(bucketName, objectName, io.Reader, contentType) (int, error)](examples/s3/putobject.go)
* [GetObject(bucketName, objectName) (*Object, error)](examples/s3/getobject.go)
* [StatObject(bucketName, objectName) (ObjectInfo, error)](examples/s3/statobject.go)
* [RemoveObject(bucketName, objectName) error](examples/s3/removeobject.go)
* [RemoveIncompleteUpload(bucketName, objectName) <-chan error](examples/s3/removeincompleteupload.go)
### File Object Operations.
* [FPutObject(bucketName, objectName, filePath, contentType) (size, error)](examples/s3/fputobject.go)
* [FGetObject(bucketName, objectName, filePath) error](examples/s3/fgetobject.go)
### API Reference : Bucket Operations
* [`MakeBucket`](https://docs.minio.io/docs/golang-client-api-reference#MakeBucket)
* [`ListBuckets`](https://docs.minio.io/docs/golang-client-api-reference#ListBuckets)
@@ -131,6 +127,11 @@ The full API Reference is available here.
* [`GetBucketPolicy`](https://docs.minio.io/docs/golang-client-api-reference#GetBucketPolicy)
* [`RemoveBucketPolicy`](https://docs.minio.io/docs/golang-client-api-reference#RemoveBucketPolicy)
### API Reference : File Object Operations
* [`FPutObject`](https://docs.minio.io/docs/golang-client-api-reference#FPutObject)
* [`FGetObject`](https://docs.minio.io/docs/golang-client-api-reference#FPutObject)
* [`CopyObject`](https://docs.minio.io/docs/golang-client-api-reference#CopyObject)
### API Reference : Object Operations
* [`GetObject`](https://docs.minio.io/docs/golang-client-api-reference#GetObject)
* [`PutObject`](https://docs.minio.io/docs/golang-client-api-reference#PutObject)
@@ -147,7 +148,6 @@ The full API Reference is available here.
## Full Examples
#### Full Examples : Bucket Operations
* [listbuckets.go](./examples/s3/listbuckets.go)
* [listobjects.go](./examples/s3/listobjects.go)
* [bucketexists.go](./examples/s3/bucketexists.go)
@@ -160,8 +160,12 @@ The full API Reference is available here.
* [getbucketpolicy.go](./examples/s3/getbucketpolicy.go)
* [removebucketpolicy.go](./examples/s3/removebucketpolicy.go)
#### Full Examples : Object Operations
#### Full Examples : File Object Operations
* [fputobject.go](./examples/s3/fputobject.go)
* [fgetobject.go](./examples/s3/fgetobject.go)
* [copyobject.go](./examples/s3/copyobject.go)
#### Full Examples : Object Operations
* [putobject.go](./examples/s3/putobject.go)
* [getobject.go](./examples/s3/getobject.go)
* [listobjects.go](./examples/s3/listobjects.go)
+14 -5
View File
@@ -163,8 +163,8 @@ func (c Client) SetBucketPolicy(bucketName string, objectPrefix string, bucketPo
}
// For bucket policy set to 'none' we need to remove the policy.
if bucketPolicy == BucketPolicyNone && policy.Statements == nil {
// No policies to set, return success.
return nil
// No policy exists on the given prefix so return with ErrNoSuchBucketPolicy.
return ErrNoSuchBucketPolicy(fmt.Sprintf("No policy exists on %s/%s", bucketName, objectPrefix))
}
// Remove any previous policies at this path.
statements := removeBucketPolicyStatement(policy.Statements, bucketName, objectPrefix)
@@ -176,10 +176,19 @@ func (c Client) SetBucketPolicy(bucketName string, objectPrefix string, bucketPo
}
statements = append(statements, generatedStatements...)
// No change in the statements indicates an attempt of setting 'none' on a prefix
// which doesn't have a pre-existing policy.
// No change in the statements indicates either an attempt of setting 'none'
// on a prefix which doesn't have a pre-existing policy, or setting a policy
// on a prefix which already has the same policy.
if reflect.DeepEqual(policy.Statements, statements) {
return ErrNoSuchBucketPolicy(fmt.Sprintf("No policy exists on %s/%s", bucketName, objectPrefix))
// If policy being set is 'none' return an error, otherwise return nil to
// prevent the unnecessary request from being sent
var err error
if bucketPolicy == BucketPolicyNone {
err = ErrNoSuchBucketPolicy(fmt.Sprintf("No policy exists on %s/%s", bucketName, objectPrefix))
} else {
err = nil
}
return err
}
policy.Statements = statements
+3 -3
View File
@@ -43,10 +43,10 @@
"revisionTime": "2015-10-24T22:24:27-07:00"
},
{
"checksumSHA1": "bXpHtM5cY97+PPqHcE+MlLqaL1k=",
"checksumSHA1": "G6QXGfja2wLChq/ApguwR45Ry94=",
"path": "github.com/minio/minio-go",
"revision": "b3e8c08bdb75538fe13e6caca515d0ee3c8021d0",
"revisionTime": "2016-06-22T22:44:24Z"
"revision": "d67b14f9c6c4d87a47372e4ae9fc4d33d4048ab5",
"revisionTime": "2016-07-04T10:06:10Z"
},
{
"path": "github.com/minio/minio/pkg/atomic",