You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zh...@apache.org on 2025/02/09 03:59:45 UTC
(dubbo-kubernetes) branch dubboctl_v13 created (now 65a88da5)
This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a change to branch dubboctl_v13
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
at 65a88da5 [chore] Added deletion of namespace resources and optimized content
This branch includes the following new commits:
new 65a88da5 [chore] Added deletion of namespace resources and optimized content
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(dubbo-kubernetes) 01/01: [chore] Added deletion of namespace resources and optimized content
Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch dubboctl_v13
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
commit 65a88da5715e28eced6f760215a3b247a1a2acb7
Author: mfordjody <11...@qq.com>
AuthorDate: Sun Feb 9 11:59:30 2025 +0800
[chore] Added deletion of namespace resources and optimized content
---
operator/pkg/uninstall/uninstaller.go | 1 +
pkg/art/art.go | 4 ---
pkg/art/dubbo-ascii.txt | 10 +++----
pkg/config/schema/gvk/resources.gen.go | 4 +++
pkg/config/schema/gvr/resource.gen.go | 1 +
pkg/kube/client_config.go | 12 ++++----
pkg/kube/client_factory.go | 7 -----
pkg/kube/collection/{schemas.go => collection.go} | 12 ++++----
pkg/kube/informerfactory/factory.go | 1 +
pkg/kube/util.go | 34 +++++++++++------------
10 files changed, 41 insertions(+), 45 deletions(-)
diff --git a/operator/pkg/uninstall/uninstaller.go b/operator/pkg/uninstall/uninstaller.go
index 5a8cb50d..c4e2b465 100644
--- a/operator/pkg/uninstall/uninstaller.go
+++ b/operator/pkg/uninstall/uninstaller.go
@@ -75,6 +75,7 @@ func NamespacedResources() []schema.GroupVersionKind {
gvk.Secret.Kubernetes(),
gvk.ServiceAccount.Kubernetes(),
gvk.Job.Kubernetes(),
+ gvk.Namespace.Kubernetes(),
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "RoleBinding"},
{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "Role"},
}
diff --git a/pkg/art/art.go b/pkg/art/art.go
index b42671f3..8c5c5d38 100644
--- a/pkg/art/art.go
+++ b/pkg/art/art.go
@@ -8,10 +8,6 @@ import (
//go:embed dubbo-ascii.txt
var dubboASCIIArt string
-func dubboArt() string {
- return dubboASCIIArt
-}
-
func DubboColoredArt() string {
return color.New(color.FgHiBlue).Add(color.Bold).Sprint(dubboASCIIArt)
}
diff --git a/pkg/art/dubbo-ascii.txt b/pkg/art/dubbo-ascii.txt
index 962d6bc9..aea3d77e 100644
--- a/pkg/art/dubbo-ascii.txt
+++ b/pkg/art/dubbo-ascii.txt
@@ -1,5 +1,5 @@
- ____ _ _
-| _ \ _ _| |__ | |__ ___
-| | | | | | | |_ \| |_ \ / _ \
-| |_| | |_| | |_| | |_| | |_| |
-|____/ \____|____/|____/ \___/
\ No newline at end of file
+ ____ _ _
+| _ \ _ _ | |__ | |__ ___
+| | | | | | | | | |_ \ | |_ \ / _ \
+| |_| | | |_| | | |_| | | |_| | | |_| |
+|____/ \____| |____/ |____/ \___/
\ No newline at end of file
diff --git a/pkg/config/schema/gvk/resources.gen.go b/pkg/config/schema/gvk/resources.gen.go
index bc557fa0..824c913d 100644
--- a/pkg/config/schema/gvk/resources.gen.go
+++ b/pkg/config/schema/gvk/resources.gen.go
@@ -31,6 +31,8 @@ func ToGVR(g config.GroupVersionKind) (schema.GroupVersionResource, bool) {
return gvr.Service, true
case ServiceAccount:
return gvr.ServiceAccount, true
+ case Namespace:
+ return gvr.Namespace, true
case Job:
return gvr.Job, true
}
@@ -48,6 +50,8 @@ func FromGVR(g schema.GroupVersionResource) (config.GroupVersionKind, bool) {
switch g {
case gvr.CustomResourceDefinition:
return CustomResourceDefinition, true
+ case gvr.Namespace:
+ return Namespace, true
case gvr.Deployment:
return Deployment, true
case gvr.StatefulSet:
diff --git a/pkg/config/schema/gvr/resource.gen.go b/pkg/config/schema/gvr/resource.gen.go
index 38010c23..d0b6cae0 100644
--- a/pkg/config/schema/gvr/resource.gen.go
+++ b/pkg/config/schema/gvr/resource.gen.go
@@ -7,6 +7,7 @@ var (
Deployment = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}
StatefulSet = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "statefulsets"}
Job = schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "jobs"}
+ Namespace = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}
Secret = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "secrets"}
Service = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}
ServiceAccount = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "serviceaccounts"}
diff --git a/pkg/kube/client_config.go b/pkg/kube/client_config.go
index 679fe02f..2e38435d 100644
--- a/pkg/kube/client_config.go
+++ b/pkg/kube/client_config.go
@@ -10,6 +10,12 @@ type clientConfig struct {
restConfig rest.Config
}
+func NewClientConfigForRestConfig(restConfig *rest.Config) clientcmd.ClientConfig {
+ return &clientConfig{
+ restConfig: *restConfig,
+ }
+}
+
func (c clientConfig) RawConfig() (api.Config, error) {
cfg := api.Config{
Kind: "Config",
@@ -39,9 +45,3 @@ func (c clientConfig) Namespace() (string, bool, error) {
func (c clientConfig) ConfigAccess() clientcmd.ConfigAccess {
return nil
}
-
-func NewClientConfigForRestConfig(restConfig *rest.Config) clientcmd.ClientConfig {
- return &clientConfig{
- restConfig: *restConfig,
- }
-}
diff --git a/pkg/kube/client_factory.go b/pkg/kube/client_factory.go
index 0ed87376..e0c528e0 100644
--- a/pkg/kube/client_factory.go
+++ b/pkg/kube/client_factory.go
@@ -24,13 +24,6 @@ type clientFactory struct {
discoveryClient laziness.Laziness[discovery.CachedDiscoveryInterface]
}
-type restClientGetter interface {
- ToRestConfig() (*rest.Config, error)
- ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- ToRestMapper() (meta.RESTMapper, error)
- ToRawKubeConfigLoader() clientcmd.ClientConfig
-}
-
func newClientFactory(clientConfig clientcmd.ClientConfig, diskCache bool) *clientFactory {
cf := &clientFactory{
clientConfig: clientConfig,
diff --git a/pkg/kube/collection/schemas.go b/pkg/kube/collection/collection.go
similarity index 100%
rename from pkg/kube/collection/schemas.go
rename to pkg/kube/collection/collection.go
index b18f2b57..de78518b 100644
--- a/pkg/kube/collection/schemas.go
+++ b/pkg/kube/collection/collection.go
@@ -33,12 +33,6 @@ func NewSchemasBuilder() *SchemasBuilder {
return &SchemasBuilder{schemas: s}
}
-func (b *SchemasBuilder) Build() Schemas {
- s := b.schemas
- b.schemas = Schemas{}
- return s
-}
-
func (b *SchemasBuilder) Add(s schema.Schema) error {
if _, found := b.schemas.byCollection[s.GroupVersionKind()]; found {
return fmt.Errorf("collection already exists: %v", s.GroupVersionKind())
@@ -54,3 +48,9 @@ func (b *SchemasBuilder) MustAdd(s schema.Schema) *SchemasBuilder {
}
return b
}
+
+func (b *SchemasBuilder) Build() Schemas {
+ s := b.schemas
+ b.schemas = Schemas{}
+ return s
+}
diff --git a/pkg/kube/informerfactory/factory.go b/pkg/kube/informerfactory/factory.go
index a1b014c7..ad558820 100644
--- a/pkg/kube/informerfactory/factory.go
+++ b/pkg/kube/informerfactory/factory.go
@@ -103,6 +103,7 @@ func (f *informerFactory) Shutdown() {
f.lock.Lock()
defer f.lock.Unlock()
+
f.shuttingDown = true
}
diff --git a/pkg/kube/util.go b/pkg/kube/util.go
index 91afa2db..251b1c92 100644
--- a/pkg/kube/util.go
+++ b/pkg/kube/util.go
@@ -27,23 +27,6 @@ func BuildClientConfig(kubeconfig, context string) (*rest.Config, error) {
return c, nil
}
-func SetRestDefaults(config *rest.Config) *rest.Config {
- if config.GroupVersion == nil || config.GroupVersion.Empty() {
- config.GroupVersion = &corev1.SchemeGroupVersion
- }
- if len(config.APIPath) == 0 {
- if len(config.GroupVersion.Group) == 0 {
- config.APIPath = "/api"
- } else {
- config.APIPath = "/apis"
- }
- }
- if config.NegotiatedSerializer == nil {
- config.NegotiatedSerializer = serializer.NewCodecFactory(nil).WithoutConversion()
- }
- return config
-}
-
func BuildClientCmd(kubeconfig, context string, overrides ...func(configOverrides *clientcmd.ConfigOverrides)) clientcmd.ClientConfig {
if kubeconfig != "" {
info, err := os.Stat(kubeconfig)
@@ -63,3 +46,20 @@ func BuildClientCmd(kubeconfig, context string, overrides ...func(configOverride
}
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
}
+
+func SetRestDefaults(config *rest.Config) *rest.Config {
+ if config.GroupVersion == nil || config.GroupVersion.Empty() {
+ config.GroupVersion = &corev1.SchemeGroupVersion
+ }
+ if len(config.APIPath) == 0 {
+ if len(config.GroupVersion.Group) == 0 {
+ config.APIPath = "/api"
+ } else {
+ config.APIPath = "/apis"
+ }
+ }
+ if config.NegotiatedSerializer == nil {
+ config.NegotiatedSerializer = serializer.NewCodecFactory(nil).WithoutConversion()
+ }
+ return config
+}