Skip to content

Add support to pass env vars to in addition to args to configure cmk - #220

Open
vishesh92 wants to merge 1 commit into
mainfrom
add-env-vars-support
Open

Add support to pass env vars to in addition to args to configure cmk#220
vishesh92 wants to merge 1 commit into
mainfrom
add-env-vars-support

Conversation

@vishesh92

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings September 1, 2026 08:00
@vishesh92 vishesh92 added this to the 6.6.0 milestone Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

✅ Build complete for PR #220.

📦 Binary artifacts are available in the workflow run (expires on September 11, 2026).

Note: Download artifacts by clicking on the workflow run link above, then scroll to the "Artifacts" section.
Artifacts from PR builds are for testing only and may contain unreviewed, malicious code.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md Outdated
Comment thread cmk.go
Comment thread cmk.go
Comment thread cmd/command.go Outdated
Copilot AI review requested due to automatic review settings September 1, 2026 09:29
@vishesh92
vishesh92 force-pushed the add-env-vars-support branch from 306f2a4 to a2b40f1 Compare September 1, 2026 09:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmk.go
Comment on lines 55 to +79
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 {
Comment thread cmk.go
Comment on lines +79 to +83
if !*debug {
if value, err := strconv.ParseBool(strings.TrimSpace(os.Getenv(config.DebugEnvVar))); err == nil && value {
*debug = true
}
}
Comment thread README.md
Comment on lines +88 to +96
| 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`) |
Comment thread cmd/command.go
Comment on lines +73 to +74
-s CloudStack user's secret Key (env: CMK_SECRET_KEY)
-k CloudStack user's API Key (env: CMK_API_KEY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants