-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add support for using predefined ACLs, fixes #324 #326
Add support for using predefined ACLs, fixes #324 #326
Conversation
Similarly to https://github.com/fog/fog-aws/blob/master/lib/fog/aws/requests/storage/put_object_acl.rb#L39, allow the use of predefined ACLs by checking the input parameter.
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.
Some files could not be reviewed due to errors:
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in...
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in .rubocop.yml `Style/IfUnlessModifier: MaxLineLength` has been removed. Use `Metrics/LineLength: Max` instead
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.
Some files could not be reviewed due to errors:
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in...
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in .rubocop.yml `Style/IfUnlessModifier: MaxLineLength` has been removed. Use `Metrics/LineLength: Max` instead
@@ -34,10 +38,16 @@ def put_object_acl(bucket_name, object_name, acl) | |||
</Entries> | |||
</AccessControlList> | |||
DATA | |||
else |
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.
could you instead change this to an else if where you check if it's a string, and check if it's a valid ACL?
We're also already storing ACLs in a few places. Could you move this list to consistent place as a constant and have all uses of ACL names reference it?
fog-google/lib/fog/storage/google_xml/models/file.rb
Lines 20 to 36 in 1b01326
# https://cloud.google.com/storage/docs/access-control#predefined-acl VALID_ACLS = [ "authenticated-read", "bucket-owner-full-control", "bucket-owner-read", "private", "project-private", "public-read", "public-read-write" ].freeze def acl=(new_acl) unless VALID_ACLS.include?(new_acl) raise ArgumentError.new("acl must be one of [#{VALID_ACLS.join(', ')}]") end @acl = new_acl end valid_acls = ["private", "public-read", "public-read-write", "authenticated-read"]
Thanks!
Sorry this review has taken so long @easkay, been running around a lot lately. This overall looks good, but I'd like us to refactor a little to be consistent with how we use shared ACLs. |
@icco No worries, thanks for taking a look. I'll work on your feedback later this evening and update the PR. I notice there's no mock for this request either, do you have any suggestions on making one? Not a problem if you don't :) |
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.
Some files could not be reviewed due to errors:
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in...
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in .rubocop.yml `Style/IfUnlessModifier: MaxLineLength` has been removed. Use `Metrics/LineLength: Max` instead
@easkay I was hoping you could update the File and Directory models as well that are using public acls. As for mocks, usually copying the response from google by making the request with curl and then scrubbing data is how it's been done in the past. |
@icco Ah, sorry I misunderstood and/or misread. I'll get on that in a few minutes :) Apologies for the misunderstanding. |
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.
Some files could not be reviewed due to errors:
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in...
Error: obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in .rubocop.yml `Style/IfUnlessModifier: MaxLineLength` has been removed. Use `Metrics/LineLength: Max` instead
@icco I wasn't entirely sure where these should live. Utils seems like a good place on the surface of it, what do you think? |
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.
Looks great!
Thanks so much! |
@icco You're very welcome, glad I could help :) |
As per issue #324, I decided to make a start on this functionality and would like to know what folks think. I'm not sure which tests need writing and where, especially since things are migrating to minitest. Some guidance would be appreciated.
Also, the changes introduced here are pretty much entirely copied from https://github.com/fog/fog-aws/blob/master/lib/fog/aws/requests/storage/put_object_acl.rb#L39.