Skip to content

Commit e8a60ca

Browse files
committed
updated to use output of yaml or json
Signed-off-by: Christian Hernandez <christian@chernand.io>
1 parent 83ede6c commit e8a60ca

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/cli/whoami/whoami.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ func (o *WhoAmIOptions) getWebConsoleUrl() (string, error) {
141141
}
142142

143143
func (o *WhoAmIOptions) Run() error {
144+
var err error
145+
o.UserInterface, err = userv1typedclient.NewForConfig(o.ClientConfig)
146+
if err != nil {
147+
return err
148+
}
149+
144150
switch {
145151
case o.ShowToken:
146152
fmt.Fprintf(o.Out, "%s\n", o.ClientConfig.BearerToken)
@@ -159,7 +165,7 @@ func (o *WhoAmIOptions) Run() error {
159165
fmt.Fprintf(o.Out, "%s\n", consoleUrl)
160166
return nil
161167
case o.Output == "yaml":
162-
u, err := o.WhoAmI()
168+
u, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{})
163169
if err != nil {
164170
return err
165171
}
@@ -171,7 +177,7 @@ func (o *WhoAmIOptions) Run() error {
171177
fmt.Fprintf(o.Out, "%s\n", string(y))
172178
return nil
173179
case o.Output == "json":
174-
u, err := o.WhoAmI()
180+
u, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{})
175181
if err != nil {
176182
return err
177183
}
@@ -183,12 +189,6 @@ func (o *WhoAmIOptions) Run() error {
183189
return nil
184190
}
185191

186-
var err error
187-
o.UserInterface, err = userv1typedclient.NewForConfig(o.ClientConfig)
188-
if err != nil {
189-
return err
190-
}
191-
192192
_, err = o.WhoAmI()
193193

194194
return err

0 commit comments

Comments
 (0)