Skip to content

Commit

Permalink
Fix kubectl auth can-i exit errcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Borja Aranda committed May 11, 2018
1 parent e59ae29 commit 9fa269a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions hack/make-rules/test-cmd-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/auth/cani.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 9fa269a

Please sign in to comment.