Skip to content

setup bucket with ip filter#49

Open
shubhangi-google wants to merge 6 commits into
mainfrom
set_bucket_ip_filter_1
Open

setup bucket with ip filter#49
shubhangi-google wants to merge 6 commits into
mainfrom
set_bucket_ip_filter_1

Conversation

@shubhangi-google

Copy link
Copy Markdown
Owner

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rake ci in the gem subdirectory.
  • Update code documentation if necessary.

closes: #<issue_number_goes_here>

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

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

  • IP Filter Support: Introduces functionality to manage IP filters for Google Cloud Storage buckets, allowing for network access control.
  • Bucket Class Extension: Adds ip_filter getter and setter methods to the Google::Cloud::Storage::Bucket class, enabling programmatic access and modification of IP filter settings.
  • Bucket Creation with IP Filter: Extends the create_bucket method in Google::Cloud::Storage::Project to accept an ip_filter parameter, allowing IP filter configuration during bucket creation.
  • New Sample Code: Adds new sample methods (create_bucket_with_ip_filter, removes_bucket_ip_filter, update_bucket_with_ip_filter) to demonstrate how to use the new IP filter features.
  • Debugging Code Present: Includes require 'pry' and binding.pry in test and sample files, indicating ongoing development and debugging efforts.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@shubhangi-google shubhangi-google changed the title wip-- create bucket with ip filter working setup bucket with ip filter Jan 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb Outdated
Comment thread google-cloud-storage/samples/acceptance/buckets_test.rb Outdated
Comment thread google-cloud-storage/samples/acceptance/buckets_test.rb Outdated
Comment thread google-cloud-storage/samples/acceptance/buckets_test.rb Outdated
Comment thread google-cloud-storage/samples/acceptance/buckets_test.rb Outdated
Comment thread google-cloud-storage/samples/acceptance/buckets_test.rb Outdated
Comment thread google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb Outdated
Comment thread google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb Outdated
Comment thread google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb Outdated
Comment thread google-cloud-storage/samples/storage_create_bucket_with_ip_filter.rb Outdated
@shubhangi-google

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread google-cloud-storage/lib/google/cloud/storage/bucket.rb
Comment thread google-cloud-storage/lib/google/cloud/storage/project.rb
Comment on lines +63 to +64
require_relative "../storage_move_object"
require 'pry'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Remove leftover require 'pry' used for debugging.

require_relative "../storage_move_object"

Comment thread google-cloud-storage/samples/storage_get_bucket_ip_filter.rb
Comment thread google-cloud-storage/samples/storage_list_bucket_ip_filters.rb
#
# @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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems these values are not correct

#
def ip_filter= new_ip_filter
@gapi.ip_filter = new_ip_filter || {}
patch_gapi! :ip_filter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

values only enabled and disabled

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@shubhangi-google resolve the conflict as well

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.

2 participants