Skip to content
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

Merged
merged 4 commits into from
May 3, 2018

Conversation

easkay
Copy link
Contributor

@easkay easkay commented Apr 23, 2018

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.

Copy link

@houndci-bot houndci-bot left a 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

Copy link

@houndci-bot houndci-bot left a 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
Copy link
Member

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?

  • # 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!

@icco
Copy link
Member

icco commented Apr 30, 2018

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.

@easkay
Copy link
Contributor Author

easkay commented Apr 30, 2018

@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 :)

Copy link

@houndci-bot houndci-bot left a 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
Copy link
Member

icco commented May 1, 2018

@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.

@easkay
Copy link
Contributor Author

easkay commented May 1, 2018

@icco Ah, sorry I misunderstood and/or misread. I'll get on that in a few minutes :) Apologies for the misunderstanding.

Copy link

@houndci-bot houndci-bot left a 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
Copy link
Contributor Author

easkay commented May 3, 2018

@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?

Copy link
Member

@icco icco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@icco icco merged commit b9c224d into fog:master May 3, 2018
@icco
Copy link
Member

icco commented May 3, 2018

Thanks so much!

@easkay
Copy link
Contributor Author

easkay commented May 3, 2018

@icco You're very welcome, glad I could help :)

@easkay easkay deleted the allow_predefined_acls_with_put_object_acl branch May 3, 2018 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants