Skip to content

refactor(auth): move kubeconfig machinery to internal/kubeconfig - #461

Merged
thde merged 2 commits into
mainfrom
thde/352-04-cluster-login
Oct 6, 2026
Merged

thde merged 2 commits into
mainfrom
thde/352-04-cluster-login

Conversation

@thde

@thde thde commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Building the kubeconfig entries (newAPIConfig with its options and the two exec plugin configs), merging them into the user's kubeconfig (login, mergeKubeConfig) and logging in to a KubernetesCluster were unexported helpers of the auth verb, which forced create to import auth for ClusterCmd. They now live in the non-verb package internal/kubeconfig as NewAPIConfig, Login and LoginCluster; auth keeps the kong commands and flag parsing and delegates to it.

The exec plugin args need the name of the auth command, so the "auth" constant moves next to api.OIDCCmdName as api.AuthCmdName and auth.CmdName refers to it.

The cluster login test moves with the logic; auth keeps a test for its name/project argument parsing.

@thde
thde added this pull request to stack #459 September 17, 2026 10:57
Base automatically changed from thde/352-03-secret-helpers to main September 30, 2026 09:55
@thde
thde force-pushed the thde/352-04-cluster-login branch 3 times, most recently from c18c1e0 to ffc2b39 Compare October 1, 2026 13:27
thde added 2 commits October 1, 2026 15:59
Building the kubeconfig entries (newAPIConfig with its options and the
two exec plugin configs), merging them into the user's kubeconfig
(login, mergeKubeConfig) and logging in to a KubernetesCluster were
unexported helpers of the auth verb, which forced create to import auth
for ClusterCmd. They now live in the non-verb package
internal/kubeconfig as NewAPIConfig, Login and LoginCluster; auth keeps
the kong commands and flag parsing and delegates to it.

The exec plugin args need the name of the auth command, so the "auth"
constant moves next to api.OIDCCmdName as api.AuthCmdName and
auth.CmdName refers to it.

The cluster login test moves with the logic; auth keeps a test for its
name/project argument parsing.
create vcluster ran auth.ClusterCmd after the cluster became available,
which was the last reason for create to import the auth verb. It now
calls kubeconfig.LoginCluster directly.

This also passes the command's own writer instead of the zero-value
format.Writer of the constructed ClusterCmd, which wrote to io.Discard,
so the "added ... to kubeconfig" and "logged into cluster ..." messages
are no longer swallowed after `nctl create vcluster`.
@thde
thde force-pushed the thde/352-04-cluster-login branch from ffc2b39 to 5698c1e Compare October 1, 2026 13:59

@SaadAssaf SaadAssaf 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.

looks clean and good to me

@thde
thde merged commit 4452294 into main Oct 6, 2026
3 checks passed
@thde
thde deleted the thde/352-04-cluster-login branch October 6, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants