mirror of https://github.com/k3s-io/k3s
update describer to use dynamic client
parent
817d822ce9
commit
1fd4149ed4
|
@ -146,13 +146,8 @@ func genericDescriber(clientAccessFactory ClientAccessFactory, mapping *meta.RES
|
|||
return nil, err
|
||||
}
|
||||
|
||||
clientConfigCopy := *clientConfig
|
||||
clientConfigCopy.APIPath = dynamic.LegacyAPIPathResolverFunc(mapping.GroupVersionKind)
|
||||
gv := mapping.GroupVersionKind.GroupVersion()
|
||||
clientConfigCopy.GroupVersion = &gv
|
||||
|
||||
// used to fetch the resource
|
||||
dynamicClient, err := dynamic.NewClient(&clientConfigCopy, gv)
|
||||
dynamicClient, err := dynamic.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -192,23 +192,18 @@ func DescriberFor(kind schema.GroupKind, clientConfig *rest.Config) (printers.De
|
|||
|
||||
// GenericDescriberFor returns a generic describer for the specified mapping
|
||||
// that uses only information available from runtime.Unstructured
|
||||
func GenericDescriberFor(mapping *meta.RESTMapping, dynamic dynamic.Interface, events coreclient.EventsGetter) printers.Describer {
|
||||
func GenericDescriberFor(mapping *meta.RESTMapping, dynamic dynamic.DynamicInterface, events coreclient.EventsGetter) printers.Describer {
|
||||
return &genericDescriber{mapping, dynamic, events}
|
||||
}
|
||||
|
||||
type genericDescriber struct {
|
||||
mapping *meta.RESTMapping
|
||||
dynamic dynamic.Interface
|
||||
dynamic dynamic.DynamicInterface
|
||||
events coreclient.EventsGetter
|
||||
}
|
||||
|
||||
func (g *genericDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (output string, err error) {
|
||||
apiResource := &metav1.APIResource{
|
||||
Name: g.mapping.Resource.Resource,
|
||||
Namespaced: g.mapping.Scope.Name() == meta.RESTScopeNameNamespace,
|
||||
Kind: g.mapping.GroupVersionKind.Kind,
|
||||
}
|
||||
obj, err := g.dynamic.Resource(apiResource, namespace).Get(name, metav1.GetOptions{})
|
||||
obj, err := g.dynamic.Resource(g.mapping.Resource).Namespace(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue