fix: support multiple paths in KUBECONFIG - #148
Merged
lucasMesquitaBorges merged 2 commits intoSep 4, 2026
Merged
Conversation
KUBECONFIG may list several kubeconfig files to merge, but the whole value was used as a single path: clientcmd got it as ExplicitPath, and auto-detect ran os.Stat on the joined string, so Gonzo silently fell back to system logs. Let client-go resolve the location instead of reimplementing it. BuildClientset now starts from NewDefaultClientConfigLoadingRules, which splits and merges KUBECONFIG and falls back to ~/.kube/config, and sets ExplicitPath only for --k8s-kubeconfig. As in kubectl, that flag stays a single file; merging is a KUBECONFIG feature. Auto-detect loads the merged config and checks that it holds at least one context. Closes control-theory#147
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The core behavior change is correct and covered by a focused unit test, with only minor follow-up nits noted in review comments.
Pull request overview
Updates Gonzo’s Kubernetes kubeconfig handling to correctly support KUBECONFIG values containing multiple paths by delegating splitting/merging behavior to client-go’s standard loading rules, aligning behavior with kubectl.
Changes:
- Switch kubeconfig resolution in
BuildClientsettoclientcmd.NewDefaultClientConfigLoadingRules()and only setExplicitPathfor--k8s-kubeconfig. - Update auto-detection to load the merged kubeconfig and require at least one context before enabling Kubernetes streaming.
- Add unit tests for multi-path
KUBECONFIGbehavior and update docs/help text to describe the new default behavior.
File summaries
| File | Description |
|---|---|
| README.md | Updates CLI flag documentation to reflect $KUBECONFIG-aware default kubeconfig behavior. |
| internal/k8s/config.go | Uses client-go loading rules for kubeconfig detection and clientset construction (supports merged configs). |
| internal/k8s/config_test.go | Adds coverage for DetectKubeconfig across single/multi-path and missing/empty config cases. |
| guides/KUBERNETES_USAGE.md | Documents multi-path KUBECONFIG merging behavior and updates kubeconfig default text. |
| cmd/gonzo/app.go | Updates log-source auto-detection to use merged kubeconfig detection instead of os.Stat on a single path string. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KUBECONFIG may list several kubeconfig files to merge, but the whole value was used as a single path: clientcmd got it as ExplicitPath, and auto-detect ran os.Stat on the joined string, so Gonzo silently fell back to system logs.
Let client-go resolve the location instead of reimplementing it. BuildClientset now starts from NewDefaultClientConfigLoadingRules, which splits and merges KUBECONFIG and falls back to ~/.kube/config, and sets ExplicitPath only for --k8s-kubeconfig. As in kubectl, that flag stays a single file; merging is a KUBECONFIG feature. Auto-detect loads the merged config and checks that it holds at least one context.
Closes #147