cli-runtime: Return defined error from Builder

There is a custom error message returned from resource.Builder when
SingleResourceType is set and multiple resources types are specified,
which makes it impossible to check for the condition in code easily.

This patch adds resource.ErrMultipleResourceTypes that is returned
precisely in this case so that it can be checked.

This patch also removes an extra custom error message in kubectl get,
which is actually never reached, because the builder fails before.

Kubernetes-commit: 82896feebbdf1c0809c0fec29988eff15cb02837
This commit is contained in:
Ondra Kupka 2025-08-04 22:48:57 +02:00 committed by Kubernetes Publisher
parent dbaaf4eb89
commit cf8aed98eb

View file

@ -629,9 +629,6 @@ func (o *GetOptions) watch(f cmdutil.Factory, args []string) error {
}
return err
}
if multipleGVKsRequested(infos) {
return i18n.Errorf("watch is only supported on individual resources and resource collections - more than 1 resource was found")
}
info := infos[0]
mapping := info.ResourceMapping()