mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
prevent "No resources found" output on forbidden error
This commit is contained in:
parent
733a381ec4
commit
df0077f362
@ -454,7 +454,7 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
if nonEmptyObjCount == 0 && !o.IgnoreNotFound {
|
if nonEmptyObjCount == 0 && !o.IgnoreNotFound && len(allErrs) == 0 {
|
||||||
fmt.Fprintln(o.ErrOut, "No resources found.")
|
fmt.Fprintln(o.ErrOut, "No resources found.")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
|
@ -72,6 +72,10 @@ run_kubectl_get_tests() {
|
|||||||
# Pre-condition: no pods exist
|
# Pre-condition: no pods exist
|
||||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||||
# Command
|
# Command
|
||||||
|
output_message=$(! kubectl get foobar 2>&1 "${kube_flags[@]}")
|
||||||
|
# Post-condition: The text "No resources found" should not be part of the output when an error occurs
|
||||||
|
kube::test::if_has_not_string "${output_message}" 'No resources found'
|
||||||
|
# Command
|
||||||
output_message=$(kubectl get pods 2>&1 "${kube_flags[@]}")
|
output_message=$(kubectl get pods 2>&1 "${kube_flags[@]}")
|
||||||
# Post-condition: The text "No resources found" should be part of the output
|
# Post-condition: The text "No resources found" should be part of the output
|
||||||
kube::test::if_has_string "${output_message}" 'No resources found'
|
kube::test::if_has_string "${output_message}" 'No resources found'
|
||||||
|
Loading…
Reference in New Issue
Block a user