mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +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 {
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user