Add support to pass env vars to in addition to args to configure cmk - #220
Add support to pass env vars to in addition to args to configure cmk#220vishesh92 wants to merge 1 commit into
Conversation
|
✅ Build complete for PR #220. 📦 Binary artifacts are available in the workflow run (expires on September 11, 2026).
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Adds support for configuring cmk via environment variables that mirror existing CLI flags, with documented precedence rules.
Changes:
- Introduces env-var constants for the supported configuration knobs.
- Applies env-var fallbacks in
main()when CLI flags aren’t provided. - Updates help text and README documentation to list supported environment variables and precedence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| config/config.go | Adds env-var constant names and improves config-file-not-found error output. |
| cmk.go | Implements env-var fallback logic for CLI flags before config loading. |
| cmd/command.go | Updates CLI help text to document env-var equivalents and precedence. |
| README.md | Documents supported environment variables and intended precedence vs flags/config. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
306f2a4 to
a2b40f1
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| args := flag.Args() | ||
|
|
||
| // Fall back to environment variables for flags not passed on the | ||
| // command line; CLI flags take precedence over environment variables. | ||
| if *configFilePath == "" { | ||
| *configFilePath = os.Getenv(config.ConfigFileEnvVar) | ||
| } | ||
| if *profile == "" { | ||
| *profile = os.Getenv(config.ProfileEnvVar) | ||
| } | ||
| if *acsURL == config.DefaultACSAPIEndpoint { | ||
| if value := os.Getenv(config.URLEnvVar); value != "" { | ||
| *acsURL = value | ||
| } | ||
| } | ||
| if *apiKey == "" { | ||
| *apiKey = os.Getenv(config.APIKeyEnvVar) | ||
| } | ||
| if *secretKey == "" { | ||
| *secretKey = os.Getenv(config.SecretKeyEnvVar) | ||
| } | ||
| if *outputFormat == "" { | ||
| *outputFormat = os.Getenv(config.OutputEnvVar) | ||
| } | ||
| if !*debug { |
| if !*debug { | ||
| if value, err := strconv.ParseBool(strings.TrimSpace(os.Getenv(config.DebugEnvVar))); err == nil && value { | ||
| *debug = true | ||
| } | ||
| } |
| | Environment variable | Flag | Description | | ||
| |----------------------|------|-------------| | ||
| | `CMK_CONFIG` | `-c` | Config file path | | ||
| | `CMK_PROFILE` | `-p` | Server profile | | ||
| | `CMK_URL` | `-u` | CloudStack's API endpoint URL | | ||
| | `CMK_API_KEY` | `-k` | CloudStack user's API key | | ||
| | `CMK_SECRET_KEY` | `-s` | CloudStack user's secret key | | ||
| | `CMK_OUTPUT` | `-o` | API response output format | | ||
| | `CMK_DEBUG` | `-d` | Enable debug mode when set to a boolean true value (e.g. `true` or `1`) | |
| -s CloudStack user's secret Key (env: CMK_SECRET_KEY) | ||
| -k CloudStack user's API Key (env: CMK_API_KEY) |
No description provided.