From 9fa269a5e5e8ce6e8359f70bb1020d18eba1cd8f Mon Sep 17 00:00:00 2001 From: Borja Aranda Date: Thu, 8 Feb 2018 16:46:11 +0100 Subject: [PATCH] Fix kubectl auth can-i exit errcode --- hack/make-rules/test-cmd-util.sh | 6 ++++++ pkg/kubectl/cmd/auth/cani.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hack/make-rules/test-cmd-util.sh b/hack/make-rules/test-cmd-util.sh index 5c60b50e931..6149a9d7b72 100755 --- a/hack/make-rules/test-cmd-util.sh +++ b/hack/make-rules/test-cmd-util.sh @@ -5219,6 +5219,12 @@ runTests() { output_message=$(kubectl auth can-i list jobs.batch/bar -n foo --quiet 2>&1 "${kube_flags[@]}") kube::test::if_empty_string "${output_message}" + + output_message=$(kubectl auth can-i get pods --subresource=log 2>&1 "${kube_flags[@]}"; echo $?) + kube::test::if_has_string "${output_message}" '0' + + output_message=$(kubectl auth can-i get pods --subresource=log --quiet 2>&1 "${kube_flags[@]}"; echo $?) + kube::test::if_has_string "${output_message}" '0' fi # kubectl auth reconcile diff --git a/pkg/kubectl/cmd/auth/cani.go b/pkg/kubectl/cmd/auth/cani.go index 88a93d8d229..a0a538f59ad 100644 --- a/pkg/kubectl/cmd/auth/cani.go +++ b/pkg/kubectl/cmd/auth/cani.go @@ -97,7 +97,7 @@ func NewCmdCanI(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C allowed, err := o.RunAccessCheck() if err == nil { - if o.Quiet && !allowed { + if !allowed { os.Exit(1) } }