aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/cloud/storage/acl.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/cloud/storage/acl.go')
-rw-r--r--vendor/google.golang.org/cloud/storage/acl.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/vendor/google.golang.org/cloud/storage/acl.go b/vendor/google.golang.org/cloud/storage/acl.go
index 1c7be32..e4d968b 100644
--- a/vendor/google.golang.org/cloud/storage/acl.go
+++ b/vendor/google.golang.org/cloud/storage/acl.go
@@ -96,17 +96,7 @@ func (a *ACLHandle) bucketDefaultList(ctx context.Context) ([]ACLRule, error) {
if err != nil {
return nil, fmt.Errorf("storage: error listing default object ACL for bucket %q: %v", a.bucket, err)
}
- r := make([]ACLRule, 0, len(acls.Items))
- for _, v := range acls.Items {
- if m, ok := v.(map[string]interface{}); ok {
- entity, ok1 := m["entity"].(string)
- role, ok2 := m["role"].(string)
- if ok1 && ok2 {
- r = append(r, ACLRule{Entity: ACLEntity(entity), Role: ACLRole(role)})
- }
- }
- }
- return r, nil
+ return toACLRules(acls.Items), nil
}
func (a *ACLHandle) bucketDefaultSet(ctx context.Context, entity ACLEntity, role ACLRole) error {
@@ -169,17 +159,7 @@ func (a *ACLHandle) objectList(ctx context.Context) ([]ACLRule, error) {
if err != nil {
return nil, fmt.Errorf("storage: error listing object ACL for bucket %q, file %q: %v", a.bucket, a.object, err)
}
- r := make([]ACLRule, 0, len(acls.Items))
- for _, v := range acls.Items {
- if m, ok := v.(map[string]interface{}); ok {
- entity, ok1 := m["entity"].(string)
- role, ok2 := m["role"].(string)
- if ok1 && ok2 {
- r = append(r, ACLRule{Entity: ACLEntity(entity), Role: ACLRole(role)})
- }
- }
- }
- return r, nil
+ return toACLRules(acls.Items), nil
}
func (a *ACLHandle) objectSet(ctx context.Context, entity ACLEntity, role ACLRole) error {
@@ -202,3 +182,17 @@ func (a *ACLHandle) objectDelete(ctx context.Context, entity ACLEntity) error {
}
return nil
}
+
+func toACLRules(items []interface{}) []ACLRule {
+ r := make([]ACLRule, 0, len(items))
+ for _, v := range items {
+ if m, ok := v.(map[string]interface{}); ok {
+ entity, ok1 := m["entity"].(string)
+ role, ok2 := m["role"].(string)
+ if ok1 && ok2 {
+ r = append(r, ACLRule{Entity: ACLEntity(entity), Role: ACLRole(role)})
+ }
+ }
+ }
+ return r
+}