feat: add --set-secrets option to deploy command#734
Conversation
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
Summary of ChangesHello @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 Highlights
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 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.
.../deployment_targets/agent_engine/python/{{cookiecutter.agent_directory}}/app_utils/deploy.py
Outdated
Show resolved
Hide resolved
.../deployment_targets/agent_engine/python/{{cookiecutter.agent_directory}}/app_utils/deploy.py
Outdated
Show resolved
Hide resolved
- 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)
…#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)
Summary
--set-secretsCLI option for Secret Manager integrationENV_VAR=SECRET_IDorENV_VAR=SECRET_ID:VERSION[secret:ID:VERSION]in deployment logsparse_key_value_pairsfor secret parsingformat_env_valuehelper for consistent env var displayProblem
Agent Engine supports Secret Manager secrets via the
env_varsdict with{"secret": ID, "version": VERSION}format, but there was no CLI option to specify secrets during deployment.Solution
Added
--set-secretsoption that:ENV_VAR=SECRET_ID:VERSIONpairslatestversion when not specifiedenv_varswith proper dict format