tolerate discovery errors in the restmapper

This commit is contained in:
David Eads
2017-11-06 08:22:44 -05:00
parent 210626577b
commit 8203b0b135

View File

@@ -79,8 +79,11 @@ func (e shortcutExpander) RESTMappings(gk schema.GroupKind, versions ...string)
func (e shortcutExpander) getShortcutMappings() ([]kubectl.ResourceShortcuts, error) {
res := []kubectl.ResourceShortcuts{}
// get server resources
// This can return an error *and* the results it was able to find. We don't need to fail on the error.
apiResList, err := e.discoveryClient.ServerResources()
if err == nil {
if err != nil {
glog.V(1).Infof("Error loading discovery information: %v", err)
}
for _, apiResources := range apiResList {
for _, apiRes := range apiResources.APIResources {
for _, shortName := range apiRes.ShortNames {
@@ -97,7 +100,6 @@ func (e shortcutExpander) getShortcutMappings() ([]kubectl.ResourceShortcuts, er
}
}
}
}
// append hardcoded short forms at the end of the list
res = append(res, kubectl.ResourcesShortcutStatic...)