Merge pull request #10532 from feihujiang/outputErrorWhenUsingDescribeForNonexist

Output error when using kubectl describe for a nonexisting resource
This commit is contained in:
Nikhil Jindal 2015-07-02 11:07:19 -07:00
commit 09a57fadfb

View File

@ -115,9 +115,11 @@ func DescribeMatchingResources(mapper meta.RESTMapper, typer runtime.ObjectTyper
if err != nil {
return err
}
isFound := false
for ix := range infos {
info := infos[ix]
if strings.HasPrefix(info.Name, prefix) {
isFound = true
s, err := describer.Describe(info.Namespace, info.Name)
if err != nil {
return err
@ -125,5 +127,8 @@ func DescribeMatchingResources(mapper meta.RESTMapper, typer runtime.ObjectTyper
fmt.Fprintf(out, "%s\n", s)
}
}
if !isFound {
return fmt.Errorf("%v %q not found", rsrc, prefix)
}
return nil
}