Skip to content

Commit

Permalink
updated to use output of yaml or json
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hernandez <[email protected]>
  • Loading branch information
christianh814 committed Jan 20, 2023
1 parent 83ede6c commit e8a60ca
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/cli/whoami/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit e8a60ca

Please sign in to comment.