Merge pull request #62877 from deads2k/cli-34-describer
Automatic merge from submit-queue (batch tested with PRs 62982, 63075, 63067, 62877, 63141). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. make describers more generic from the CLI I've made this change very small so the intent and explanation make sense to people. Clients are not generic. Client**Configs** are generic. We faced this distinction in the apiserver and it took us a little to hurdle it. When you try to provide a generic example or function, you need to provide Client**Config**, not a kube clientset. The reason is that the code you're calling may have generated their own clientset, may want to use a dynamic one, or may want to a simple restclient. As we seek to make `kubectl` primitives more generally applicable, this is an example we'll want to follow. I suspect we'll be making more changes along these veins as we tease out the generic pieces of `kubectl ` to make a friendly CLI library. @kubernetes/sig-cli-maintainers /hold Holding for a few days to make sure that people have time to read and digest. ```release-note NONE ```
This commit is contained in:
@@ -164,16 +164,12 @@ func (f *ring1Factory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (
|
||||
}
|
||||
|
||||
func (f *ring1Factory) Describer(mapping *meta.RESTMapping) (printers.Describer, error) {
|
||||
clientset, err := f.clientAccessFactory.ClientSet()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
externalclientset, err := f.clientAccessFactory.KubernetesClientSet()
|
||||
clientConfig, err := f.clientAccessFactory.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// try to get a describer
|
||||
if describer, ok := printersinternal.DescriberFor(mapping.GroupVersionKind.GroupKind(), clientset, externalclientset); ok {
|
||||
if describer, ok := printersinternal.DescriberFor(mapping.GroupVersionKind.GroupKind(), clientConfig); ok {
|
||||
return describer, nil
|
||||
}
|
||||
// if this is a kind we don't have a describer for yet, go generic if possible
|
||||
|
Reference in New Issue
Block a user