Skip to content

fix: honor CLI config defaults#1746

Merged
jmhbh merged 3 commits intokagent-dev:mainfrom
AkashKumar7902:issue-973-cli-config-values
Apr 27, 2026
Merged

fix: honor CLI config defaults#1746
jmhbh merged 3 commits intokagent-dev:mainfrom
AkashKumar7902:issue-973-cli-config-values

Conversation

@AkashKumar7902
Copy link
Copy Markdown
Contributor

@AkashKumar7902 AkashKumar7902 commented Apr 24, 2026

Fixes #973

Summary

  • Load ~/.kagent/config.yaml before constructing Cobra commands so saved values become the CLI defaults.
  • Keep explicit flags as overrides by binding command flags to the same shared config object.
  • Use the loaded namespace as the deploy --namespace default so registering that command does not reset the configured namespace.

Testing

  • go test ./core/cli/cmd/kagent
  • go test ./core/cli/internal/config ./core/cli/cmd/kagent
  • go test ./core/cli/...
  • go test -race -skip 'TestE2E.*' ./core/cli/...
  • go vet ./core/cli/cmd/kagent ./core/cli/internal/config
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.3 run ./core/cli/cmd/kagent ./core/cli/internal/config
  • git diff --check
  • Temporary-HOME smoke check: go run ./core/cli/cmd/kagent --help shows config-file defaults for --kagent-url, --namespace, --output-format, and --timeout.

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Copilot AI review requested due to automatic review settings April 24, 2026 22:15
@AkashKumar7902 AkashKumar7902 changed the title Honor CLI config defaults fix: honor CLI config defaults Apr 24, 2026
@github-actions github-actions Bot added the bug Something isn't working label Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 fixes CLI behavior so values stored in ~/.kagent/config.yaml are loaded first and then used as Cobra flag defaults, while still allowing explicit CLI flags to override them. This addresses issue #973 where commands like kagent dashboard did not honor the configured namespace.

Changes:

  • Initialize/load config before constructing Cobra commands and pass the shared config object through execution.
  • Bind persistent flag defaults to the loaded config values (instead of hardcoded defaults).
  • Use the loaded namespace as the deploy --namespace default and add tests covering config-file defaults and flag overrides.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
go/core/cli/cmd/kagent/main.go Loads config before building commands; uses loaded config values as flag defaults; ensures interactive mode uses the same config instance.
go/core/cli/cmd/kagent/main_test.go Adds tests validating config file loading, default propagation into flags, and CLI flag override behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@jmhbh jmhbh left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution

@jmhbh jmhbh enabled auto-merge (squash) April 27, 2026 21:53
@jmhbh jmhbh merged commit 90212ab into kagent-dev:main Apr 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI config values are not used

5 participants