Skip to content

Commit 98d990d

Browse files
committed
return config err if any
1 parent f37ba7b commit 98d990d

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
kclientcmd "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
1313
kclientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
1414
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
15-
kutilerrors "k8s.io/kubernetes/pkg/util/errors"
1615

1716
"github.com/openshift/origin/pkg/client"
1817
"github.com/openshift/origin/pkg/cmd/cli/config"
@@ -125,26 +124,21 @@ func (o LogoutOptions) RunLogout() error {
125124
return err
126125
}
127126

128-
errs := []error{}
129127
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.")
128+
if serverErr != nil {
129+
glog.V(1).Infof("%v\n", serverErr)
138130
}
139131

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

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

147-
return nil
141+
return configErr
148142
}
149143

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

0 commit comments

Comments
 (0)