-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(storage): add UpdateBucketACL implementation #5974
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start! A few comments.
@@ -986,11 +986,17 @@ func (ua *BucketAttrsToUpdate) toProtoBucket() *storagepb.Bucket { | |||
lifecycle = *ua.Lifecycle | |||
} | |||
var bktACL []*storagepb.BucketAccessControl | |||
if ua.acl != nil { | |||
bktACL = toProtoBucketACL(ua.acl) | |||
} | |||
if ua.PredefinedACL != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very confused about what is going on with PredefinedACL and PredefinedDefaultObjectACL here... it doesn't seem like they are actually being set on the returned bucket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, one cannot provide both a predefinedAcl and an acl while patching/updating a bucket. I tried out buckets.patch and buckets.update with the JSON API, and it results in a 409 conflict error.
So in the library code here,, PredefinedACL and PredefinedDefaultObjectACL take precedence and therefore clears ACLs.
That being said, I believe I need to handle the updateMask with more care under the update semantics. Let me know if this clarifies your question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, gotcha. Yeah I think ForceSendFields plays the same role for JSON that the updateMask plays for gRPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the review, Chris! Added some inline comments. Hopefully that's clearer for readers and our future selves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just a couple more little things
storage/http_client.go
Outdated
acl, err = req.Do() | ||
aclRule = toBucketACLRule(acl) | ||
return err | ||
}, s.retry, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use s.idempotent
so we can set it above the interface
@@ -986,11 +986,17 @@ func (ua *BucketAttrsToUpdate) toProtoBucket() *storagepb.Bucket { | |||
lifecycle = *ua.Lifecycle | |||
} | |||
var bktACL []*storagepb.BucketAccessControl | |||
if ua.acl != nil { | |||
bktACL = toProtoBucketACL(ua.acl) | |||
} | |||
if ua.PredefinedACL != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, gotcha. Yeah I think ForceSendFields plays the same role for JSON that the updateMask plays for gRPC
storage/grpc_client.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
aclRule := b.ACL[len(b.ACL)-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just return the ACLRule we sent rather than picking the last one off the list (I'm not sure if the ordering is guaranteed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This adds UpdateBucketACL implementation
acl
anddefaultObjectACL
toBucketAttrsToUpdate