type RESTMapper errors to better handle MultiRESTMapper errors
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/errors"
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
@@ -118,6 +119,22 @@ func checkErr(err error, handleErr func(string)) {
|
||||
handleErr(MultilineError(prefix, errs))
|
||||
}
|
||||
|
||||
if meta.IsNoResourceMatchError(err) {
|
||||
noMatch := err.(*meta.NoResourceMatchError)
|
||||
|
||||
switch {
|
||||
case len(noMatch.PartialResource.Group) > 0 && len(noMatch.PartialResource.Version) > 0:
|
||||
handleErr(fmt.Sprintf("the server doesn't have a resource type %q in group %q and version %q", noMatch.PartialResource.Resource, noMatch.PartialResource.Group, noMatch.PartialResource.Version))
|
||||
case len(noMatch.PartialResource.Group) > 0:
|
||||
handleErr(fmt.Sprintf("the server doesn't have a resource type %q in group %q", noMatch.PartialResource.Resource, noMatch.PartialResource.Group))
|
||||
case len(noMatch.PartialResource.Version) > 0:
|
||||
handleErr(fmt.Sprintf("the server doesn't have a resource type %q in version %q", noMatch.PartialResource.Resource, noMatch.PartialResource.Version))
|
||||
default:
|
||||
handleErr(fmt.Sprintf("the server doesn't have a resource type %q", noMatch.PartialResource.Resource))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// handle multiline errors
|
||||
if clientcmd.IsConfigurationInvalid(err) {
|
||||
handleErr(MultilineError("Error in configuration: ", err))
|
||||
|
Reference in New Issue
Block a user