Skip to content

sample: delete samples/snippets directory#1964

Closed
chalmerlowe wants to merge 20 commits intomainfrom
chore-delete-samples
Closed

sample: delete samples/snippets directory#1964
chalmerlowe wants to merge 20 commits intomainfrom
chore-delete-samples

Conversation

@chalmerlowe
Copy link
Contributor

Deletes the samples/snippets directory following a relocation of the samples to the python-docs-samples repo.

Moved in preparaation

amtk3 and others added 20 commits January 15, 2026 15:07
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Added `CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE` and `CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH` as fallback environment variables for mTLS configuration.
Updated `google/auth/transport/_mtls_helper.py` to check these variables if the primary `GOOGLE_API_...` variables are not set.
Added tests to verify precedence and fallback logic.
…6834227

Add fallback environment variables for mTLS configuration
feat (iam): Add Cloud SDK context-aware mTLS env var fallbacks and define the env in environment_vars.py
@chalmerlowe chalmerlowe requested a review from a team February 26, 2026 18:11
@chalmerlowe chalmerlowe requested review from a team as code owners February 26, 2026 18:11
@chalmerlowe chalmerlowe requested a review from dandhlee February 26, 2026 18:11
@snippet-bot
Copy link

snippet-bot bot commented Feb 26, 2026

Here is the summary of possible violations 😱

Details

There are 2 possible violations for removing region tag in use.

The end of the violation section. All the stuff below is FYI purposes only.


Here is the summary of changes.

You are about to delete 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Feb 26, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chalmerlowe, 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 primarily focuses on two distinct areas: the removal of outdated sample code and enhancements to mTLS configuration. The samples/snippets directory has been deleted following the relocation of its contents to a dedicated samples repository, streamlining project structure. Concurrently, the mTLS implementation has been improved by introducing new environment variables that offer greater flexibility and fallback options for client certificate management, ensuring robust and adaptable secure communication.

Highlights

  • Sample Code Removal: The samples/snippets directory has been entirely removed, as its contents were relocated to the python-docs-samples repository to centralize sample management.
  • mTLS Configuration Enhancements: New environment variables (CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE and CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH) have been introduced to provide more flexible and Cloud SDK context-aware control over mTLS client certificate usage and configuration file paths. These variables act as fallbacks to existing GOOGLE_API_ prefixed variables.
  • mTLS Logic Refactoring: The internal mTLS helper logic has been updated to incorporate the new environment variables, ensuring proper precedence and fallback mechanisms for determining whether to use client certificates and where to find their configuration.
  • Expanded mTLS Test Coverage: New unit tests have been added to validate the precedence and fallback behavior of the mTLS environment variables, ensuring the new configuration logic functions as expected.
Changelog
  • google/auth/environment_vars.py
    • Added CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE environment variable for mTLS client certificate control.
    • Added CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH environment variable for mTLS certificate configuration file path.
  • google/auth/iam.py
    • Removed os import as it is no longer directly used in this file.
    • Updated mTLS determination logic to use _mtls_helper.check_use_client_cert() for consistency and centralized control.
  • google/auth/transport/_mtls_helper.py
    • Modified _get_cert_config_path to include CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH as a fallback for certificate configuration.
    • Updated check_use_client_cert to prioritize GOOGLE_API_USE_CLIENT_CERTIFICATE and fallback to CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE for determining client certificate usage.
    • Implemented fallback logic in check_use_client_cert to check for certificate configuration file paths if explicit use_client_cert variables are not set.
  • samples/cloud-client/snippets/authenticate_explicit_with_adc.py
    • Removed file.
  • samples/cloud-client/snippets/authenticate_implicit_with_adc.py
    • Removed file.
  • samples/cloud-client/snippets/custom_aws_supplier.py
    • Removed file.
  • samples/cloud-client/snippets/custom_okta_supplier.py
    • Removed file.
  • samples/cloud-client/snippets/idtoken_from_impersonated_credentials.py
    • Removed file.
  • samples/cloud-client/snippets/idtoken_from_metadata_server.py
    • Removed file.
  • samples/cloud-client/snippets/idtoken_from_service_account.py
    • Removed file.
  • samples/cloud-client/snippets/noxfile.py
    • Removed file.
  • samples/cloud-client/snippets/noxfile_config.py
    • Removed file.
  • samples/cloud-client/snippets/requirements.txt
    • Removed file.
  • samples/cloud-client/snippets/snippets_test.py
    • Removed file.
  • samples/cloud-client/snippets/verify_google_idtoken.py
    • Removed file.
  • tests/transport/test__mtls_helper.py
    • Imported environment_vars to access new environment variable names.
    • Added test cases for _get_cert_config_path to verify precedence between GOOGLE_API_CERTIFICATE_CONFIG and CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH.
    • Added test cases for _get_cert_config_path to verify fallback to CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH.
    • Added test cases for check_use_client_cert to verify precedence between GOOGLE_API_USE_CLIENT_CERTIFICATE and CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE.
    • Added test cases for check_use_client_cert to verify fallback to CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE.
    • Added a test case for check_use_client_cert to verify fallback to certificate config file presence when no explicit use_client_cert variables are set.
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
Contributor

@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 primarily removes the samples/snippets directory. It also introduces fallback environment variables for mTLS configuration and updates the logic to use them. The new logic is correct and is accompanied by tests. I've suggested a few minor refactorings in google/auth/transport/_mtls_helper.py to improve code conciseness and readability by using or for fallback logic. Overall, the changes look good.

Comment on lines +462 to +466
use_client_cert = getenv(environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE)
if use_client_cert is None or use_client_cert == "":
use_client_cert = getenv(
environment_vars.CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for determining use_client_cert can be made more concise by using the or operator.

    use_client_cert = getenv(
        environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE
    ) or getenv(environment_vars.CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE)

Comment on lines +473 to +477
cert_path = getenv(environment_vars.GOOGLE_API_CERTIFICATE_CONFIG)
if cert_path is None:
cert_path = getenv(
environment_vars.CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logic for determining cert_path can also be simplified using the or operator. This also makes the handling of an empty string consistent with how use_client_cert is handled.

        cert_path = getenv(
            environment_vars.GOOGLE_API_CERTIFICATE_CONFIG
        ) or getenv(
            environment_vars.CLOUDSDK_CONTEXT_AWARE_CERTIFICATE_CONFIG_FILE_PATH
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants