Skip to content

feat: add merge-to-default-kubeconfig command#162

Merged
MichaelSp merged 4 commits into
mainfrom
feat/merge-to-default-kubeconfig
Jul 6, 2026
Merged

feat: add merge-to-default-kubeconfig command#162
MichaelSp merged 4 commits into
mainfrom
feat/merge-to-default-kubeconfig

Conversation

@MichaelSp

Copy link
Copy Markdown
Owner

Summary

  • Adds kswitch merge-to-default-kubeconfig command that merges the currently selected $KUBECONFIG into ~/.kube/config
  • Clusters, contexts, and users with matching names are overwritten by the selected config's versions
  • current-context in ~/.kube/config is set to the selected config's current-context
  • Creates ~/.kube/config if it doesn't exist

Warning

As noted in the command description: existing entries with the same name are silently overwritten. Destructive by design.

Changes

  • cmd/kswitch/merge.go — cobra command registration
  • pkg/subcommands/merge-to-default/merge.go — YAML-level merge logic (no external deps beyond gopkg.in/yaml.v3)
  • pkg/subcommands/merge-to-default/merge_test.go — unit tests for add-new, overwrite-existing, empty-dst cases
  • pkg/util/kubectx_copied/kubeconfig.go — added Path() accessor

Test plan

  • kswitch merge-to-default-kubeconfig with a kswitch-selected context merges into ~/.kube/config
  • Re-running overwrites same-named entries
  • current-context in ~/.kube/config is updated
  • Unit tests pass: go test ./pkg/subcommands/merge-to-default/...

MichaelSp added 3 commits July 6, 2026 14:19
Merges the currently selected KUBECONFIG into ~/.kube/config.
Clusters, contexts, and users with matching names are overwritten;
current-context is updated to the selected config's current-context.

Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
@MichaelSp MichaelSp enabled auto-merge (squash) July 6, 2026 15:25
Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
@MichaelSp MichaelSp merged commit 433a02c into main Jul 6, 2026
5 checks passed
@MichaelSp MichaelSp deleted the feat/merge-to-default-kubeconfig branch July 6, 2026 15:44
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.

1 participant