mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
make api-resource discovery errors non-fatal
This commit is contained in:
parent
da59a6da4a
commit
b20a8c6b04
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||||
@ -136,9 +137,10 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
discoveryclient.Invalidate()
|
discoveryclient.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errs := []error{}
|
||||||
lists, err := discoveryclient.ServerPreferredResources()
|
lists, err := discoveryclient.ServerPreferredResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resources := []groupResource{}
|
resources := []groupResource{}
|
||||||
@ -192,7 +194,7 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
name += "." + r.APIGroup
|
name += "." + r.APIGroup
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(w, "%s\n", name); err != nil {
|
if _, err := fmt.Fprintf(w, "%s\n", name); err != nil {
|
||||||
return err
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
case "wide":
|
case "wide":
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\t%v\n",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\t%v\n",
|
||||||
@ -202,7 +204,7 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
r.APIResource.Namespaced,
|
r.APIResource.Namespaced,
|
||||||
r.APIResource.Kind,
|
r.APIResource.Kind,
|
||||||
r.APIResource.Verbs); err != nil {
|
r.APIResource.Verbs); err != nil {
|
||||||
return err
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
case "":
|
case "":
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\n",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%v\t%s\n",
|
||||||
@ -211,10 +213,14 @@ func (o *APIResourceOptions) RunAPIResources(cmd *cobra.Command, f cmdutil.Facto
|
|||||||
r.APIGroup,
|
r.APIGroup,
|
||||||
r.APIResource.Namespaced,
|
r.APIResource.Namespaced,
|
||||||
r.APIResource.Kind); err != nil {
|
r.APIResource.Kind); err != nil {
|
||||||
return err
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(errs) > 0 {
|
||||||
|
return errors.NewAggregate(errs)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user