Repository navigation
Switch context with every file listed in $KUBECONFIG - #6
Merged
Merged
Conversation
With $KUBECONFIG listing several files, k10s connected to the current
context, but switching to another one failed with
load kubeconfig: stat a.yaml:b.yaml: no such file or directory
The first connection passes no path, so client-go applies kubectl's
loading rules and merges the list. SwitchContext rebuilt the store
from Client.ConfigPath instead, which holds the whole list for
plugins, and client-go took it as the one explicit file to load.
The client now remembers the path it was asked to load ("" for
kubectl's rules), and a context switch loads the same way. ConfigPath
is unchanged, so plugins still get the full list in $KUBECONFIG.
Member
|
Reviewed, approving. Verified locally on Go 1.27.1: The diagnosis is right: Merging. Thanks for the regression test. |
pierreneter
approved these changes
Oct 7, 2026
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.
With
KUBECONFIGlisting several files, which kubectl merges (one file per cluster is a common layout), k10s connects to the current context, but switching to another one with:ctxfails:The first connection goes through
NewStore("", ctx), so client-go applies its own loading rules and merges the list.Store.SwitchContextrebuilt the store fromClient.ConfigPathinstead. That field holds the wholeKUBECONFIGvalue on purpose, for plugins (TestLoadedKubeconfigPathPreservesMergedKubeconfigList), and client-go took it as the one explicit file to load.The client now remembers the path it was asked to load (
""for kubectl's rules), andSwitchContextloads the same way.ConfigPathis unchanged, so plugins still get the full list.TestSwitchContextWithKubeconfigListwrites two kubeconfig files with one context each, connects through the merged list and switches to the context that lives in the second file. On main it fails with the error above.Checked with
gofmt,go vet ./...andgo test ./...on Go 1.26.8, and a build for each release platform.