From 967fdbd3d52b67ed5c72f2b4888adae1f04489e1 Mon Sep 17 00:00:00 2001 From: "m.nabokikh" Date: Tue, 27 Sep 2022 15:49:51 +0200 Subject: [PATCH] Fix the code according to the code review comments Signed-off-by: m.nabokikh --- staging/src/k8s.io/kubectl/pkg/cmd/auth/whoami.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/auth/whoami.go b/staging/src/k8s.io/kubectl/pkg/cmd/auth/whoami.go index d6d8c9aa5a4..daca2adead6 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/auth/whoami.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/auth/whoami.go @@ -140,7 +140,7 @@ func NewCmdWhoAmI(restClientGetter genericclioptions.RESTClientGetter, streams g } var notEnabledErr = fmt.Errorf( - "the selfsubjectreviews API is not enabled in the cluster or you do not have permission to call: " + + "the selfsubjectreviews API is not enabled in the cluster or you do not have permission to call\n" + "enable APISelfSubjectReview feature gate and authentication.k8s.io/v1alpha1 API") // Run prints all user attributes. @@ -148,14 +148,11 @@ func (o WhoAmIOptions) Run() error { sar := &authenticationv1alpha1.SelfSubjectReview{} response, err := o.authClient.SelfSubjectReviews().Create(context.TODO(), sar, metav1.CreateOptions{}) if err != nil { - switch { - case errors.IsForbidden(err), errors.IsNotFound(err): + if errors.IsForbidden(err) || errors.IsNotFound(err) { return notEnabledErr - default: - return err } + return err } - return o.resourcePrinterFunc(response, o.Out) }