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 75bbd77d [dubboctl] Fix typo and add k8s client config
75bbd77d is described below
commit 75bbd77d5b7e76259f8adf32dda85f3420d0ff94
Author: mfordjody <[email protected]>
AuthorDate: Mon Dec 9 08:53:32 2024 +0800
[dubboctl] Fix typo and add k8s client config
---
dubboctl/pkg/cli/context.go | 17 ++++++++++++-----
pkg/kube/client_config.go | 32 ++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/dubboctl/pkg/cli/context.go b/dubboctl/pkg/cli/context.go
index 1d90182d..7daf2b69 100644
--- a/dubboctl/pkg/cli/context.go
+++ b/dubboctl/pkg/cli/context.go
@@ -7,7 +7,7 @@ import (
)
type instance struct {
- client map[string]kube.CLIClient
+ clients map[string]kube.CLIClient
RootFlags
}
@@ -35,16 +35,23 @@ func (i *instance) CLIClient() (kube.CLIClient, error) {
}
func (i *instance) CLIClientWithRevision(rev string) (kube.CLIClient, error) {
- if i.client == nil {
- i.client = make(map[string]kube.CLIClient)
+ if i.clients == nil {
+ i.clients = make(map[string]kube.CLIClient)
}
-
+ impersonationConfig := rest.ImpersonationConfig{}
+ client, err := newKubeClientWithRevision(*i.kubeconfig, *i.Context,
impersonationConfig)
+ if err != nil {
+ return nil, err
+ }
+ i.clients[rev] = client
+ return i.clients[rev], nil
}
-func newKubeClientWithRevision(kubeconfig, context, revision string)
(kube.CLIClient, error) {
+func newKubeClientWithRevision(kubeconfig, context, revision string,
impersonationConfig rest.ImpersonationConfig) (kube.CLIClient, error) {
drc, err := kube.DefaultRestConfig(kubeconfig, context, func(config
*rest.Config) {
config.QPS = 50
config.Burst = 100
+ config.Impersonate = impersonationConfig
})
if err != nil {
return nil, err
diff --git a/pkg/kube/client_config.go b/pkg/kube/client_config.go
new file mode 100644
index 00000000..42cbdd63
--- /dev/null
+++ b/pkg/kube/client_config.go
@@ -0,0 +1,32 @@
+package kube
+
+import (
+ "k8s.io/client-go/rest"
+ "k8s.io/client-go/tools/clientcmd"
+)
+
+type clientConfig struct {
+ restConfig rest.Config
+}
+
+func (c clientConfig) RawConfig() (api.Config, error) {
+ panic("implement me")
+}
+
+func (c clientConfig) ClientConfig() (*rest.Config, error) {
+ panic("implement me")
+}
+
+func (c clientConfig) Namespace() (string, bool, error) {
+ panic("implement me")
+}
+
+func (c clientConfig) ConfigAccess() clientcmd.ConfigAccess {
+ panic("implement me")
+}
+
+func NewClientConfigForRestConfig(restConfig *rest.Config)
clientcmd.ClientConfig {
+ return &clientConfig{
+ restConfig: *restConfig,
+ }
+}