Improve kubectl "get" error message

Previous behavior:
$ kubectl get hosts
F1119 11:47:44.787154   29017 resource.go:111] no resource "hosts" has been defined
This commit is contained in:
Haney Maxwell 2014-11-19 11:59:39 -08:00
parent 3c3ad74711
commit bc29903146

View File

@ -44,7 +44,10 @@ func ResourceFromArgsOrFile(cmd *cobra.Command, args []string, filename string,
}
version, kind, err := mapper.VersionAndKindForResource(resource)
checkErr(err)
if err != nil {
// The error returned by mapper is "no resource defined", which is a usage error
usageError(cmd, err.Error())
}
mapping, err = mapper.RESTMapping(version, kind)
checkErr(err)