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

Fix an error when the bucket ACL doesn't exist #81

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion libraries/google_storage_bucket_acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ def initialize(opts = {})
super(opts)
@bucket = opts[:bucket]
@entity = opts[:entity]
catch_gcp_errors do
begin
@acl = @gcp.gcp_storage_client.get_bucket_access_control(@bucket, @entity)
create_resource_methods(@acl)
# all non-existing entities raise a "Not Found" client error
rescue Google::Apis::ClientError => e
# re-raise the exception if the error is not "Not Found"
raise e unless e.status_code == 404
@acl = nil
@error = JSON.parse(e.body)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
its('bucket') { should eq gcp_storage_bucket_acl }
end

end
describe google_storage_bucket_acl(bucket: gcp_storage_bucket_acl, entity: 'allUsers') do
it { should_not exist }
end
end