mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #10532 from feihujiang/outputErrorWhenUsingDescribeForNonexist
Output error when using kubectl describe for a nonexisting resource
This commit is contained in:
commit
09a57fadfb
@ -115,9 +115,11 @@ func DescribeMatchingResources(mapper meta.RESTMapper, typer runtime.ObjectTyper
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
isFound := false
|
||||||
for ix := range infos {
|
for ix := range infos {
|
||||||
info := infos[ix]
|
info := infos[ix]
|
||||||
if strings.HasPrefix(info.Name, prefix) {
|
if strings.HasPrefix(info.Name, prefix) {
|
||||||
|
isFound = true
|
||||||
s, err := describer.Describe(info.Namespace, info.Name)
|
s, err := describer.Describe(info.Namespace, info.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -125,5 +127,8 @@ func DescribeMatchingResources(mapper meta.RESTMapper, typer runtime.ObjectTyper
|
|||||||
fmt.Fprintf(out, "%s\n", s)
|
fmt.Fprintf(out, "%s\n", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !isFound {
|
||||||
|
return fmt.Errorf("%v %q not found", rsrc, prefix)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user