Support bucket encryption config update#58
Conversation
Fix missing newline at end of file in bucket_encryption_test.rb
Removed an unnecessary blank line before the encryption configuration documentation.
Removed unnecessary comment line in bucket.rb
Removed unnecessary comment line in bucket.rb.
Removed unnecessary comment line in bucket.rb
There was a problem hiding this comment.
Code Review
This pull request introduces Bucket Encryption Enforcement Config, adding attributes to the Bucket class for managing customer-managed, customer-supplied, and Google-managed encryption restrictions. The implementation includes updated internal update logic, new sample scripts, and expanded test coverage. Review feedback identifies a logic error where using || {} prevents clearing configurations with nil, the accidental disabling of existing sample tests, a missing method referenced in unit tests, a documentation typo, and the need to remove debugging artifacts like require 'pry' and unused parameters in internal helper methods.
I am having trouble creating individual review comments. Click here to see my feedback.
google-cloud-storage/lib/google/cloud/storage/bucket.rb (770)
Using || {} here prevents the configuration from being cleared when nil is passed. If the intention is to allow clearing the configuration (as suggested by the documentation and the unit tests), this should allow nil to be assigned to the underlying API object. Assigning {} will likely result in an empty object being sent in the request rather than the field being omitted or cleared.
new_customer_managed_encryption_enforcement_configgoogle-cloud-storage/lib/google/cloud/storage/bucket.rb (823)
Using || {} here prevents the configuration from being cleared when nil is passed. See the comment on line 770 for more details.
new_customer_supplied_encryption_enforcement_configgoogle-cloud-storage/lib/google/cloud/storage/bucket.rb (882)
Using || {} here prevents the configuration from being cleared when nil is passed. See the comment on line 770 for more details.
new_google_managed_encryption_enforcement_configgoogle-cloud-storage/samples/acceptance/buckets_test.rb (69-126)
A large portion of the existing tests has been commented out. These tests should be re-enabled to ensure no regressions were introduced and to maintain test coverage for the samples.
google-cloud-storage/test/google/cloud/storage/bucket_encryption_test.rb (172)
The method update_bucket_encryption_enforcement_config is called in this test but does not appear to be defined in lib/google/cloud/storage/bucket.rb. This will result in a NoMethodError when running the unit tests.
google-cloud-storage/lib/google/cloud/storage/bucket.rb (864)
There is a typo in the example method name. It should be google_managed_encryption_enforcement_config instead of new_google_managed_encryption_enforcement_config.
# bucket.google_managed_encryption_enforcement_config = new_configgoogle-cloud-storage/lib/google/cloud/storage/bucket.rb (3423-3433)
The addition of the bucket_encryption_config parameter to patch_gapi! appears to be unused in the provided changes and breaks the generic nature of this internal helper method. If it is not required for a specific reason, it should be removed to maintain code clarity and consistency.
if_metageneration_not_match: nil
attributes = Array(attributes)
attributes.flatten!
return if attributes.empty?
ensure_service!
patch_args = attributes.to_h do |attr|
[attr, @gapi.send(attr)]
endgoogle-cloud-storage/samples/acceptance/buckets_test.rb (61)
The require 'pry' statement should be removed before merging, as it is typically used for local debugging and is not appropriate for shared test code.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ciin the gem subdirectory.closes: #<issue_number_goes_here>