-
Notifications
You must be signed in to change notification settings - Fork 153
Add --from-secret and --from-env flags to set-build-env #2860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2860 +/- ##
==========================================
- Coverage 56.66% 56.58% -0.08%
==========================================
Files 322 322
Lines 31279 31449 +170
==========================================
+ Hits 17723 17796 +73
- Misses 12038 12117 +79
- Partials 1518 1536 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c8db694 to
e44e32a
Compare
Implement secure credential handling for build environment variables during protocol builds (npx://, uvx://, go://). This allows users to reference ToolHive secrets or shell environment variables instead of storing sensitive values in the configuration file. New features: - `--from-secret`: Reference a ToolHive secret by name, validated at configuration time, resolved at build time - `--from-env`: Read value from shell environment at build time Configuration model: - BuildEnvFromSecrets: maps env var names to secret names - BuildEnvFromShell: list of env var names to read from shell Security: - No sensitive values stored in config file - Secret values validated against dangerous characters - Multi-stage builds ensure credentials don't leak to final image Example usage: thv secret set npm-registry "https://:token@npm.corp.example.com" thv config set-build-env --from-secret NPM_CONFIG_REGISTRY npm-registry thv config set-build-env --from-env GITHUB_TOKEN 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
e44e32a to
3e5e8b7
Compare
Large PR justification has been provided. Thank you!
|
✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review. |
Summary
Implement secure credential handling for build environment variables during protocol builds (
npx://,uvx://,go://). This allows users to reference ToolHive secrets or shell environment variables instead of storing sensitive values in the configuration file.Closes the implementation portion of the proposal in #2859
Large PR Justification
--from-secret,--from-env, and literal value paths share validation, conflict detection, and build-time resolution logic that cannot be meaningfully separatedNew Features
--from-secretflagReference a ToolHive secret by name. The secret is validated to exist at configuration time and resolved at build time.
--from-envflagRead value from the shell environment at build time. Useful for CI/CD where secrets are injected via environment.
thv config set-build-env --from-env GITHUB_TOKEN # At build time, $GITHUB_TOKEN is read from the shellConfiguration Model
Three separate sections keep sensitive values out of the config file:
Security
--from-secretvalidates secret existsMulti-Stage Build Isolation
All protocol build templates use multi-stage Docker builds. The
BuildEnvvariables are only set in the builder stage:node_modules,package.json,package-lock.json/opt/uv-tools/app/mcp-serverbinaryChanges
pkg/config/config.go: AddBuildEnvFromSecretsandBuildEnvFromShellfieldspkg/config/interface.go: Add provider interface methodspkg/config/buildenv.go: Add helper functions and conflict checkingcmd/thv/app/config_buildenv.go: Add--from-secretand--from-envflagspkg/runner/protocol.go: Resolve values from all 3 sources at build timepkg/config/buildenv_test.go: Add unit testsTest plan
task lintpassestask testpasses--from-secretworkflow--from-envworkflow🤖 Generated with Claude Code