This is an automated email from the ASF dual-hosted git repository.

zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new d7702f12 [operator] Fix client-side factory logic bugs
d7702f12 is described below

commit d7702f127210f9bd50037df61ac8dcc6eb632857
Author: mfordjody <[email protected]>
AuthorDate: Wed Dec 11 11:58:58 2024 +0800

    [operator] Fix client-side factory logic bugs
---
 dubboctl/pkg/cli/context.go |  2 +-
 pkg/kube/client_factory.go  | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dubboctl/pkg/cli/context.go b/dubboctl/pkg/cli/context.go
index ca41448d..86e52028 100644
--- a/dubboctl/pkg/cli/context.go
+++ b/dubboctl/pkg/cli/context.go
@@ -39,7 +39,7 @@ func (i *instance) CLIClientWithRevision(rev string) 
(kube.CLIClient, error) {
                i.clients = make(map[string]kube.CLIClient)
        }
        impersonationConfig := rest.ImpersonationConfig{}
-       client, err := newKubeClientWithRevision(*i.kubeconfig, *i.Context, 
impersonationConfig)
+       client, err := newKubeClientWithRevision(*i.kubeconfig, *i.Context, 
rev, impersonationConfig)
        if err != nil {
                return nil, err
        }
diff --git a/pkg/kube/client_factory.go b/pkg/kube/client_factory.go
index a615571c..58f06193 100644
--- a/pkg/kube/client_factory.go
+++ b/pkg/kube/client_factory.go
@@ -18,7 +18,8 @@ import (
 
 type clientFactory struct {
        clientConfig    clientcmd.ClientConfig
-       mapper          laziness.Laziness[meta.RESTMapper]
+       expander        laziness.Laziness[meta.RESTMapper]
+       mapper          laziness.Laziness[meta.ResettableRESTMapper]
        discoveryClient laziness.Laziness[discovery.CachedDiscoveryInterface]
 }
 
@@ -50,6 +51,17 @@ func newClientFactory(clientConfig clientcmd.ClientConfig, 
diskCache bool) *clie
                }
                return 
restmapper.NewDeferredDiscoveryRESTMapper(discoveryClient), nil
        })
+       cf.expander = laziness.NewWithRetry(func() (meta.RESTMapper, error) {
+               discoveryClient, err := cf.discoveryClient.Get()
+               if err != nil {
+                       return nil, err
+               }
+               mapper, err := cf.mapper.Get()
+               if err != nil {
+                       return nil, err
+               }
+               return restmapper.NewShortcutExpander(mapper, discoveryClient, 
func(string) {}), nil
+       })
        return cf
 }
 

Reply via email to