feat: read sensitive CLI flags from environment variables#521
Conversation
Adds `envvar=` to the Typer options for five sensitive CLI flags so they can be supplied via environment variables instead of command-line args: - `--prometheus-auth-header` → `PROMETHEUS_AUTH_HEADER` - `--eks-access-key` → `EKS_ACCESS_KEY` - `--eks-secret-key` → `EKS_SECRET_KEY` - `--coralogix-token` → `CORALOGIX_TOKEN` - `--teams-webhook` → `TEAMS_WEBHOOK` CLI args still take precedence when both are set, so this is fully backward-compatible. Motivation: running KRR as a Kubernetes CronJob/CronWorkflow today requires passing tokens on the command line (via shell expansion of env vars), which leaves them visible to `ps` inside the container. With `envvar=` they can be mounted from a Kubernetes Secret as env vars and never appear in argv. This matches the pattern KRR already uses for `SLACK_BOT_TOKEN` (env-only).
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR extends five CLI strategy command options to accept values via environment variables. The ChangesEnvironment Variable Configuration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds
envvar=to the Typer options for five sensitive CLI flags so they can be supplied via environment variables instead of command-line args. CLI args still take precedence when both are set, so this is fully backward-compatible.--prometheus-auth-headerPROMETHEUS_AUTH_HEADER--eks-access-keyEKS_ACCESS_KEY--eks-secret-keyEKS_SECRET_KEY--coralogix-tokenCORALOGIX_TOKEN--teams-webhookTEAMS_WEBHOOKHelp text for each flag is updated to note the env-var alternative. No behavior changes when the env vars are unset.
Motivation
When running KRR as a scheduled Kubernetes job (CronJob, Argo CronWorkflow, etc.), tokens currently have to be passed on the command line — typically via shell expansion of env vars mounted from a Secret. This leaves the token visible to
psinside the container.With
envvar=, the same Secret can be mounted as env vars and KRR's PydanticBaseSettingspicks them up directly. Tokens never appear in argv.This matches the pattern KRR already uses for
SLACK_BOT_TOKEN, which is env-only.Why these five fields
These are the CLI flags whose values are credentials or signed URLs. Other flags (e.g.
--prometheus-url,--slackoutput) are not sensitive and the existing CLI-only behavior is fine for them — thoughenvvar=could be added to those too in a follow-up if useful.Backward compatibility
Example
Before:
After:
Happy to add tests or split into multiple commits/PRs if that fits your review preferences — let me know.