-
Notifications
You must be signed in to change notification settings - Fork 12
feat(cli): add comprehensive environment variable support #516
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.
Pull request overview
This PR adds comprehensive environment variable support to confd's CLI configuration, enabling users to configure the tool entirely through environment variables—particularly useful for containerized deployments in Docker and Kubernetes.
Changes:
- Added
env:tags to 28 CLI struct fields for environment variable support - Added comprehensive test coverage for environment variable parsing and CLI flag precedence
- Expanded documentation with complete environment variable reference organized by category
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/confd/cli.go | Added env: tags to 28 struct fields enabling environment variable configuration |
| cmd/confd/cli_test.go | Added test functions to verify environment variable parsing and CLI flag precedence |
| docs/command-line-flags.md | Reorganized and expanded documentation with categorized tables for all environment variables |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #516 +/- ##
==========================================
- Coverage 62.36% 62.30% -0.06%
==========================================
Files 48 48
Lines 5420 5420
==========================================
- Hits 3380 3377 -3
- Misses 1831 1834 +3
Partials 209 209 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Findings:
Question:
|
Add env: tags to CLI struct fields to enable configuration via environment variables with the CONFD_ prefix, matching user expectations for containerized deployments. New environment variables: - Core: CONFD_CONFDIR, CONFD_CONFIG_FILE, CONFD_INTERVAL, CONFD_LOG_LEVEL, CONFD_LOG_FORMAT, CONFD_PREFIX, CONFD_WATCH, CONFD_ONETIME, CONFD_NOOP, CONFD_SYNC_ONLY, CONFD_FAILURE_MODE, CONFD_KEEP_STAGE_FILE - Timeouts: CONFD_BACKEND_TIMEOUT, CONFD_CHECK_CMD_TIMEOUT, CONFD_RELOAD_CMD_TIMEOUT, CONFD_DIAL_TIMEOUT, CONFD_READ_TIMEOUT, CONFD_WRITE_TIMEOUT, CONFD_PREFLIGHT_TIMEOUT, CONFD_SHUTDOWN_TIMEOUT - Retry: CONFD_RETRY_MAX_ATTEMPTS, CONFD_RETRY_BASE_DELAY, CONFD_RETRY_MAX_DELAY - Watch: CONFD_DEBOUNCE, CONFD_BATCH_INTERVAL, CONFD_WATCH_ERROR_BACKOFF - Cache: CONFD_TEMPLATE_CACHE, CONFD_STAT_CACHE_TTL - Service Discovery: CONFD_SRV_DOMAIN, CONFD_SRV_RECORD - Observability: CONFD_WATCHDOG_INTERVAL Previously supported (unchanged): - CONFD_METRICS_ADDR, CONFD_SYSTEMD_NOTIFY - CONFD_CLIENT_CERT, CONFD_CLIENT_KEY, CONFD_CLIENT_CAKEYS Tests use clearCONFDEnvVars helper with t.Cleanup to properly save/restore environment variables and ensure hermetic tests. Fixes #513
92cfd32 to
363e587
Compare
|
Addressed the review feedback: Test fixes:
Additional env var support:
Not adding env vars for:
Documentation updated to include new service discovery section. |
Summary
Add comprehensive environment variable support for CLI configuration, enabling Docker/Kubernetes users to configure confd entirely via environment variables.
Changes
env:tags to 28 CLI struct fields incmd/confd/cli.gocmd/confd/cli_test.godocs/command-line-flags.mdwith complete env var referenceNew Environment Variables
Core Settings
CONFD_CONFDIRCONFD_CONFIG_FILECONFD_INTERVALCONFD_LOG_LEVELCONFD_LOG_FORMATCONFD_PREFIXCONFD_WATCHCONFD_ONETIMECONFD_NOOPCONFD_SYNC_ONLYCONFD_FAILURE_MODECONFD_KEEP_STAGE_FILETimeouts
CONFD_BACKEND_TIMEOUTCONFD_CHECK_CMD_TIMEOUTCONFD_RELOAD_CMD_TIMEOUTCONFD_DIAL_TIMEOUTCONFD_READ_TIMEOUTCONFD_WRITE_TIMEOUTCONFD_PREFLIGHT_TIMEOUTCONFD_SHUTDOWN_TIMEOUTRetry & Watch
CONFD_RETRY_MAX_ATTEMPTSCONFD_RETRY_BASE_DELAYCONFD_RETRY_MAX_DELAYCONFD_DEBOUNCECONFD_BATCH_INTERVALCONFD_WATCH_ERROR_BACKOFFCaching
CONFD_TEMPLATE_CACHECONFD_STAT_CACHE_TTLTest plan
TestCLIEnvVars- tests 11 env vars are parsed correctlyTestCLIEnvVarPrecedence- verifies CLI flags override env varsExample Usage
# Docker example docker run -e CONFD_INTERVAL=60 \ -e CONFD_LOG_LEVEL=debug \ -e CONFD_WATCH=true \ -e CONFD_BACKEND_TIMEOUT=45s \ confd etcd --node http://etcd:2379Fixes #513
🤖 Generated with Claude Code