Promote whoami kubectl command

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
m.nabokikh 2023-03-12 15:24:31 +01:00
parent bbbbfcd967
commit c2cadd2b60
3 changed files with 3 additions and 15 deletions

View File

@ -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() {

View File

@ -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
}

View File

@ -111,10 +111,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
`)
)