From e8a60ca02ae92e16fffeffd350b2d3d7d1877026 Mon Sep 17 00:00:00 2001 From: Christian Hernandez Date: Fri, 20 Jan 2023 07:42:57 -0800 Subject: [PATCH] updated to use output of yaml or json Signed-off-by: Christian Hernandez --- pkg/cli/whoami/whoami.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/cli/whoami/whoami.go b/pkg/cli/whoami/whoami.go index 60f9dfd7af..7b8e3ef06c 100644 --- a/pkg/cli/whoami/whoami.go +++ b/pkg/cli/whoami/whoami.go @@ -141,6 +141,12 @@ func (o *WhoAmIOptions) getWebConsoleUrl() (string, error) { } func (o *WhoAmIOptions) Run() error { + var err error + o.UserInterface, err = userv1typedclient.NewForConfig(o.ClientConfig) + if err != nil { + return err + } + switch { case o.ShowToken: fmt.Fprintf(o.Out, "%s\n", o.ClientConfig.BearerToken) @@ -159,7 +165,7 @@ func (o *WhoAmIOptions) Run() error { fmt.Fprintf(o.Out, "%s\n", consoleUrl) return nil case o.Output == "yaml": - u, err := o.WhoAmI() + u, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{}) if err != nil { return err } @@ -171,7 +177,7 @@ func (o *WhoAmIOptions) Run() error { fmt.Fprintf(o.Out, "%s\n", string(y)) return nil case o.Output == "json": - u, err := o.WhoAmI() + u, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{}) if err != nil { return err } @@ -183,12 +189,6 @@ func (o *WhoAmIOptions) Run() error { return nil } - var err error - o.UserInterface, err = userv1typedclient.NewForConfig(o.ClientConfig) - if err != nil { - return err - } - _, err = o.WhoAmI() return err