Skip to content

feat: add --set-secrets option to deploy command#734

Merged
eliasecchig merged 2 commits intomainfrom
feat/deploy-set-secrets
Jan 26, 2026
Merged

feat: add --set-secrets option to deploy command#734
eliasecchig merged 2 commits intomainfrom
feat/deploy-set-secrets

Conversation

@eliasecchig
Copy link
Collaborator

Summary

  • Add --set-secrets CLI option for Secret Manager integration
  • Accept format ENV_VAR=SECRET_ID or ENV_VAR=SECRET_ID:VERSION
  • Display secrets as [secret:ID:VERSION] in deployment logs
  • Refactor to reuse parse_key_value_pairs for secret parsing
  • Add format_env_value helper for consistent env var display

Problem

Agent Engine supports Secret Manager secrets via the env_vars dict with {"secret": ID, "version": VERSION} format, but there was no CLI option to specify secrets during deployment.

Solution

Added --set-secrets option that:

  • Parses comma-separated ENV_VAR=SECRET_ID:VERSION pairs
  • Defaults to latest version when not specified
  • Merges secrets into env_vars with proper dict format
  • Masks secret values in logs for security

Add support for Secret Manager secrets in Agent Engine deployments:
- New --set-secrets option accepts ENV_VAR=SECRET_ID or ENV_VAR=SECRET_ID:VERSION
- Secrets displayed as [secret:ID:VERSION] in deployment logs
- Refactored parse_secrets to reuse parse_key_value_pairs
- Added format_env_value helper for consistent display
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @eliasecchig, 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 deployment utility by introducing a --set-secrets command-line option. This feature allows users to seamlessly integrate Google Secret Manager secrets into their Agent Engine deployments, providing a secure and convenient way to manage sensitive configuration data. The change also ensures that secret values are masked in deployment logs, improving overall security posture and streamlining the handling of sensitive information.

Highlights

  • New CLI Option for Secrets: Added a new --set-secrets CLI option to the deploy command, enabling direct integration of Secret Manager secrets during deployment.
  • Flexible Secret Specification: The --set-secrets option accepts secrets in ENV_VAR=SECRET_ID or ENV_VAR=SECRET_ID:VERSION format, with 'latest' as the default version if not specified.
  • Secure Secret Display: Implemented a format_env_value helper function to mask secret values in deployment logs, displaying them as [secret:ID:VERSION] for enhanced security.
  • Refactored Secret Handling: Introduced a parse_secrets function that reuses parse_key_value_pairs to process secret strings and merge them into environment variables, ensuring secrets override plain environment variables.
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 introduces a --set-secrets option to the deploy command, allowing users to inject secrets from Secret Manager as environment variables. The implementation includes new helper functions for parsing and formatting secrets, and integrates this functionality into the deployment script.

My review focuses on improving the correctness and robustness of the new helper functions. I've identified a bug in the secret parsing logic that affects certain input formats and suggested a more robust implementation. I've also recommended a small change to the secret formatting function to prevent potential KeyError exceptions with malformed secret dictionaries. The overall approach and integration of the feature are well-executed.

- Check for colon existence before using rpartition in parse_secrets
- Add version key check in format_env_value to prevent KeyError
- Add type ignore comment for env_vars.update(secrets)
@eliasecchig eliasecchig merged commit 465169a into main Jan 26, 2026
34 checks passed
enriquekalven pushed a commit to enriquekalven/agent-starter-pack that referenced this pull request Feb 7, 2026
…#734)

* feat: add --set-secrets option to deploy command

Add support for Secret Manager secrets in Agent Engine deployments:
- New --set-secrets option accepts ENV_VAR=SECRET_ID or ENV_VAR=SECRET_ID:VERSION
- Secrets displayed as [secret:ID:VERSION] in deployment logs
- Refactored parse_secrets to reuse parse_key_value_pairs
- Added format_env_value helper for consistent display

* fix: address code review feedback for secret parsing

- Check for colon existence before using rpartition in parse_secrets
- Add version key check in format_env_value to prevent KeyError
- Add type ignore comment for env_vars.update(secrets)
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.

1 participant