mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
tolerate discovery errors in the restmapper
This commit is contained in:
@@ -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...)
|
||||
|
Reference in New Issue
Block a user