Skip to content

Commit 7a16da2

Browse files
committed
return config err if any
1 parent f37ba7b commit 7a16da2

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

pkg/cmd/cli/cmd/login/logout.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,21 @@ func (o LogoutOptions) RunLogout() error {
125125
return err
126126
}
127127

128-
errs := []error{}
129128
serverErr := client.OAuthAccessTokens().Delete(token)
130-
errs = append(errs, serverErr)
131-
132-
if configErr := deleteTokenFromConfig(*o.StartingKubeConfig, o.PathOptions, token); configErr != nil {
133-
errs = append(errs, configErr)
134-
} else if serverErr != nil {
135-
// if token was not able to be deleted using api but was successfully removed
136-
// from client config, log brief explanation that token was still removed locally
137-
glog.V(1).Infof("%s\n\n", "An error ocurred deleting the token on the server. The token has been removed from your local configuration.")
129+
if serverErr != nil {
130+
glog.V(1).Infof("%v\n", serverErr)
138131
}
139132

140-
err = kutilerrors.Flatten(kutilerrors.NewAggregate(errs))
141-
if err != nil {
142-
glog.V(1).Infof("%v\n", err)
143-
}
133+
configErr := deleteTokenFromConfig(*o.StartingKubeConfig, o.PathOptions, token)
134+
if configErr == nil {
135+
glog.V(1).Infof("Removed token from your local configuration.\n\n")
144136

145-
fmt.Fprintf(o.Out, "Logged %q out on %q\n", userInfo.Name, o.Config.Host)
137+
// return successful message to user, even if serverErr != nil, as long as removing
138+
// the token from the client config did not result in an error
139+
fmt.Fprintf(o.Out, "Logged %q out on %q\n", userInfo.Name, o.Config.Host)
140+
}
146141

147-
return nil
142+
return configErr
148143
}
149144

150145
func deleteTokenFromConfig(config kclientcmdapi.Config, pathOptions *kclientcmd.PathOptions, bearerToken string) error {

0 commit comments

Comments
 (0)