Skip to content

Conversation

@echo-chamber0
Copy link
Contributor

Add support for Cloud SQL private IP connections via environment variable configuration, replacing the runtime regex-based patching workaround.

Changes:

  • Import IPTypes from google.cloud.sql.connector for IP type specification
  • Add ENV_CLOUDSQL_USE_PRIVATE_IP environment variable constant (The same Env variable is expected to be used in Mixer)
  • Create extensible _CLOUDSQL_ENV_TO_PARAM mapping for optional parameters
  • Add _get_optional_cloudsql_params() helper to build optional params dict
  • Update both connection points to merge optional params using dict operator

Usage:
Set CLOUDSQL_USE_PRIVATE_IP=true to enable private IP connections. New optional parameters can be added by extending _CLOUDSQL_ENV_TO_PARAM mapping without modifying connection code.

Add support for Cloud SQL private IP connections via environment variable
configuration, replacing the runtime regex-based patching workaround.

Changes:
- Import IPTypes from google.cloud.sql.connector for IP type specification
- Add ENV_CLOUDSQL_USE_PRIVATE_IP environment variable constant
- Create extensible _CLOUDSQL_ENV_TO_PARAM mapping for optional parameters
- Add _get_optional_cloudsql_params() helper to build optional params dict
- Update both connection points to merge optional params using dict operator

Usage:
Set CLOUDSQL_USE_PRIVATE_IP=true to enable private IP connections.
New optional parameters can be added by extending _CLOUDSQL_ENV_TO_PARAM
mapping without modifying connection code.

This approach:
- Maintains consistency with existing code style
- Uses dictionary merge operator for clean integration
- Provides extensibility for future optional parameters
- Eliminates need for runtime code patching
@gemini-code-assist
Copy link

Summary of Changes

Hello @echo-chamber0, 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 significantly enhances the Cloud SQL connection mechanism by integrating native support for private IP connections. It replaces a less robust, regex-based workaround with a cleaner, environment variable-driven configuration, making the system more maintainable and extensible for future connection options and improving overall connection reliability and security.

Highlights

  • Native Private IP Support: Introduced direct support for Cloud SQL private IP connections, eliminating a previous regex-based workaround for a more robust solution.
  • Environment Variable Configuration: Enabled private IP connections to be configured via the CLOUDSQL_USE_PRIVATE_IP environment variable, simplifying setup.
  • Extensible Parameter Mapping: Implemented a new _CLOUDSQL_ENV_TO_PARAM mapping and _get_optional_cloudsql_params helper function for easily adding future optional Cloud SQL connection parameters without modifying core connection logic.
  • Updated Connection Logic: Modified existing Cloud SQL connection points to dynamically incorporate these new optional parameters, ensuring seamless integration.

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

Copy link

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

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 support for Cloud SQL private IP connections by reading an environment variable. The implementation is clean and extensible, using a mapping to convert environment variables to connection parameters. The changes are applied correctly at both connection points. I have one suggestion to refactor a helper function for better conciseness and readability, but overall the changes are solid.

@dwnoble dwnoble self-requested a review January 2, 2026 19:48
@dwnoble
Copy link
Contributor

dwnoble commented Jan 2, 2026

/gcbrun

@dwnoble
Copy link
Contributor

dwnoble commented Jan 7, 2026

/gcbrun

@dwnoble dwnoble enabled auto-merge (squash) January 7, 2026 19:15
@dwnoble
Copy link
Contributor

dwnoble commented Jan 7, 2026

@echo-chamber0 Can you run ./run_test.sh -f on this PR to fix the formatting?

auto-merge was automatically disabled January 8, 2026 08:57

Head branch was pushed to by a user without write access

@echo-chamber0 echo-chamber0 force-pushed the feat/cloud-sql-private-ip branch from e48b63d to 870ee72 Compare January 8, 2026 09:15
@echo-chamber0
Copy link
Contributor Author

@dwnoble It's done, could you please review again

@dwnoble
Copy link
Contributor

dwnoble commented Jan 8, 2026

/gcbrun

@dwnoble dwnoble enabled auto-merge (squash) January 8, 2026 19:19
@dwnoble dwnoble merged commit 471f636 into datacommonsorg:master Jan 9, 2026
6 checks passed
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