diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index b80b41d4..2afb53d5 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -32,7 +32,7 @@ }, { "ImportPath": "github.com/minio/minio-go", - "Rev": "b09ed5ab53f445d9dcee76b24154f075e9468cbb" + "Rev": "513ea3dc246f1aa25bfd0c21fe87011119b265ca" }, { "ImportPath": "github.com/minio/minio/pkg/iodine", diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/api.go b/Godeps/_workspace/src/github.com/minio/minio-go/api.go index 7b2114b8..72cf6879 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/api.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/api.go @@ -448,11 +448,6 @@ func (a *api) PutObject(bucket, object string, size uint64, data io.Reader) erro return errors.New("Unexpected control flow") } -// RemoveObject deletes an object from a bucket -func (a *api) RemoveObject(bucket, object string) error { - return a.deleteObject(bucket, object) -} - // StatObject verify if object exists and you have permission to access it func (a *api) StatObject(bucket, object string) (*ObjectStat, error) { if strings.TrimSpace(object) == "" { @@ -464,8 +459,8 @@ func (a *api) StatObject(bucket, object string) (*ObjectStat, error) { return a.headObject(bucket, object) } -// DeleteObject remove the object from a bucket -func (a *api) DeleteObject(bucket, object string) error { +// RemoveObject remove the object from a bucket +func (a *api) RemoveObject(bucket, object string) error { if strings.TrimSpace(object) == "" { return errors.New("object name cannot be empty") } @@ -540,21 +535,29 @@ func (a *api) GetBucketACL(bucket string) (BucketACL, error) { if policy.AccessControlList.Grant == nil { return "", fmt.Errorf("%s", "Unexpected error") } + grants := policy.AccessControlList.Grant switch { - case policy.AccessControlList.Grant.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && - policy.AccessControlList.Grant.Permission == "WRITE": - return BucketACL("public-read-write"), nil - case policy.AccessControlList.Grant.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && - policy.AccessControlList.Grant.Permission == "READ": - return BucketACL("public-read"), nil - case policy.AccessControlList.Grant.Grantee.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" && - policy.AccessControlList.Grant.Permission == "READ": - return BucketACL("authenticated-read"), nil - case policy.AccessControlList.Grant.Grantee.URI == "" && - policy.AccessControlList.Grant.Permission == "FULL_CONTROL": - return BucketACL("private"), nil + case len(grants) == 1: + if grants[0].Grantee.URI == "" && grants[0].Permission == "FULL_CONTROL" { + return BucketACL("private"), nil + } + case len(grants) == 2: + for _, g := range grants { + if g.Grantee.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" && g.Permission == "READ" { + return BucketACL("authenticated-read"), nil + } + if g.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && g.Permission == "READ" { + return BucketACL("public-read"), nil + } + } + case len(grants) == 3: + for _, g := range grants { + if g.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && g.Permission == "WRITE" { + return BucketACL("public-read-write"), nil + } + } } - return "", nil + return "", fmt.Errorf("Cannot verify access control policy") } // BucketExists verify if bucket exists and you have permission to access it diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/low_level_api.go b/Godeps/_workspace/src/github.com/minio/minio-go/low_level_api.go index 05bf158b..ec32a152 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/low_level_api.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/low_level_api.go @@ -182,13 +182,13 @@ func (a *lowLevelAPI) getBucketACL(bucket string) (*accessControlPolicy, error) return nil, responseToError(resp) } } - accessControlPolicy := new(accessControlPolicy) + policy := new(accessControlPolicy) decoder := xml.NewDecoder(resp.Body) - err = decoder.Decode(accessControlPolicy) + err = decoder.Decode(policy) if err != nil { return nil, err } - return accessControlPolicy, nil + return policy, nil } // getBucketLocationRequest wrapper creates a new getBucketLocation request diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/low_level_definitions.go b/Godeps/_workspace/src/github.com/minio/minio-go/low_level_definitions.go index 579e4078..bf02d0e1 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/low_level_definitions.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/low_level_definitions.go @@ -158,22 +158,20 @@ type createBucketConfiguration struct { Location string `xml:"LocationConstraint"` } -type grantee struct { - ID string - DisplayName string - EmailAddress string - Type string - URI string -} - type grant struct { - Grantee grantee + Grantee struct { + ID string + DisplayName string + EmailAddress string + Type string + URI string + } Permission string } type accessControlPolicy struct { - Owner owner AccessControlList struct { - Grant *grant + Grant []*grant } + Owner owner }