setup bucket with ip filter#49
Conversation
Summary of ChangesHello @shubhangi-google, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the capability to configure IP filters for Google Cloud Storage buckets directly through the Ruby client library. It extends existing bucket management functionalities to allow specifying IP filter settings during bucket creation and provides methods to update these settings on existing buckets. The changes also include new sample code to demonstrate the usage of this feature, although some debugging code is still present, suggesting it is a work-in-progress. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces IP filter functionality for Google Cloud Storage buckets. The core library changes in google-cloud-storage/lib/google/cloud/storage/bucket.rb and google-cloud-storage/lib/google/cloud/storage/project.rb appear to be correctly implemented. However, the sample code and acceptance tests in google-cloud-storage/samples/acceptance/buckets_test.rb and google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb contain several issues, including debugging statements (binding.pry), commented-out code, and a significant mix-up of responsibilities in the update_bucket_with_ip_filter sample, which attempts to manage IAM roles instead of solely updating the IP filter. These issues need to be addressed to ensure the samples are correct, clean, and functional.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for configuring IP filters on Google Cloud Storage buckets, including new getter/setter methods, creation parameters, sample scripts, and tests. The review feedback highlights several critical issues: the ip_filter parameter and setter should explicitly convert Hash or nil inputs into Google::Apis::StorageV1::Bucket::IpFilter objects to prevent type mismatch and runtime NoMethodError crashes; safe navigation should be used in sample scripts when accessing allowed_ip_cidr_ranges to avoid errors when it is nil; and a leftover require 'pry' debugging statement should be removed from the acceptance tests.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| require_relative "../storage_move_object" | ||
| require 'pry' |
| # | ||
| # @param [Google::Apis::StorageV1::Bucket::IpFilter, Hash] new_ip_filter The bucket's new IP filter. | ||
| # Acceptable Hash structure: | ||
| # - :mode - [String] The mode of the IP filter. Acceptable values are: "Disabled", "Enforced", "Preview" |
There was a problem hiding this comment.
seems these values are not correct
| # | ||
| def ip_filter= new_ip_filter | ||
| @gapi.ip_filter = new_ip_filter || {} | ||
| patch_gapi! :ip_filter |
There was a problem hiding this comment.
check this if you pass empty and using patch API make the API remove the existing IP filter instead of patching, check this logic
| # Acceptable values are: | ||
| # - {Google::Apis::StorageV1::Bucket::IpFilter} object | ||
| # - Hash that can be converted to a {Google::Apis::StorageV1::Bucket::IpFilter} object | ||
| # - :mode - [String] The mode of the IP filter. Acceptable values are: "Disabled", "Enforced", "Preview" |
There was a problem hiding this comment.
values only enabled and disabled
There was a problem hiding this comment.
@shubhangi-google resolve the conflict as well
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>