Output error when using kubectl describe for a nonexisting resource

This commit is contained in:
feihujiang 2015-06-30 14:12:58 +08:00
parent 835eded294
commit 55db7ec369

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
}