From e0b4d10785ce4724ee52cebcfffac856e8337bf5 Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Sun, 12 Mar 2023 15:24:31 +0100 Subject: [PATCH] Promote whoami kubectl command Signed-off-by: m.nabokikh Kubernetes-commit: c2cadd2b60424d26678b72506e377dfbf12b9876 --- pkg/cmd/alpha.go | 13 ------------- pkg/cmd/auth/auth.go | 1 + pkg/cmd/auth/whoami.go | 4 ++-- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/pkg/cmd/alpha.go b/pkg/cmd/alpha.go index b636952ef..a26689a76 100644 --- a/pkg/cmd/alpha.go +++ b/pkg/cmd/alpha.go @@ -20,7 +20,6 @@ import ( "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" - "k8s.io/kubectl/pkg/cmd/auth" cmdutil "k8s.io/kubectl/pkg/cmd/util" "k8s.io/kubectl/pkg/util/i18n" "k8s.io/kubectl/pkg/util/templates" @@ -34,18 +33,6 @@ func NewCmdAlpha(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra. Long: templates.LongDesc(i18n.T("These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.")), } - // Alpha commands should be added here. As features graduate from alpha they should move - // from here to the CommandGroups defined by NewKubeletCommand() in cmd.go. - - authCmds := &cobra.Command{ - Use: "auth", - Short: "Inspect authorization", - Long: `Inspect authorization`, - Run: cmdutil.DefaultSubCommandRun(streams.ErrOut), - } - cmd.AddCommand(authCmds) - authCmds.AddCommand(auth.NewCmdWhoAmI(f, streams)) - // NewKubeletCommand() will hide the alpha command if it has no subcommands. Overriding // the help function ensures a reasonable message if someone types the hidden command anyway. if !cmd.HasAvailableSubCommands() { diff --git a/pkg/cmd/auth/auth.go b/pkg/cmd/auth/auth.go index 79968f5b2..1af105b58 100644 --- a/pkg/cmd/auth/auth.go +++ b/pkg/cmd/auth/auth.go @@ -35,6 +35,7 @@ func NewCmdAuth(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C cmds.AddCommand(NewCmdCanI(f, streams)) cmds.AddCommand(NewCmdReconcile(f, streams)) + cmds.AddCommand(NewCmdWhoAmI(f, streams)) return cmds } diff --git a/pkg/cmd/auth/whoami.go b/pkg/cmd/auth/whoami.go index 287bfb826..7d55c7e99 100644 --- a/pkg/cmd/auth/whoami.go +++ b/pkg/cmd/auth/whoami.go @@ -121,10 +121,10 @@ var ( whoAmIExample = templates.Examples(` # Get your subject attributes. - kubectl alpha auth whoami + kubectl auth whoami # Get your subject attributes in JSON format. - kubectl alpha auth whoami -o json + kubectl auth whoami -o json `) )