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 1144b69d [operator] test uninstall logic
1144b69d is described below

commit 1144b69de428ba28f5e196a4016b68bb7c68da59
Author: mfordjody <[email protected]>
AuthorDate: Sat Dec 21 09:18:22 2024 +0800

    [operator] test uninstall logic
---
 operator/cmd/cluster/uninstall.go                     | 19 ++++++++++++++++---
 operator/pkg/install/installer.go                     |  2 +-
 .../pkg/uninstall/{uninstall.go => uninstaller.go}    |  0
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/operator/cmd/cluster/uninstall.go 
b/operator/cmd/cluster/uninstall.go
index f85f43da..0ae2ecda 100644
--- a/operator/cmd/cluster/uninstall.go
+++ b/operator/cmd/cluster/uninstall.go
@@ -1,8 +1,10 @@
 package cluster
 
 import (
+       "fmt"
        "github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli"
        "github.com/apache/dubbo-kubernetes/operator/pkg/render"
+       "github.com/apache/dubbo-kubernetes/operator/pkg/uninstall"
        "github.com/apache/dubbo-kubernetes/operator/pkg/util/clog"
        "github.com/apache/dubbo-kubernetes/operator/pkg/util/progress"
        "github.com/apache/dubbo-kubernetes/pkg/kube"
@@ -36,7 +38,7 @@ func UninstallCmd(ctx cli.Context) *cobra.Command {
   # Uninstall all control planes and shared resources
   dubboctl uninstall --purge`,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       return uninstall(cmd, ctx, rootArgs, uiArgs)
+                       return UnInstall(cmd, ctx, rootArgs, uiArgs)
                },
        }
        addFlags(uicmd, rootArgs)
@@ -44,7 +46,7 @@ func UninstallCmd(ctx cli.Context) *cobra.Command {
        return uicmd
 }
 
-func uninstall(cmd *cobra.Command, ctx cli.Context, rootArgs *RootArgs, uiArgs 
*uninstallArgs) error {
+func UnInstall(cmd *cobra.Command, ctx cli.Context, rootArgs *RootArgs, uiArgs 
*uninstallArgs) error {
        cl := clog.NewConsoleLogger(cmd.OutOrStdout(), cmd.ErrOrStderr(), 
installerScope)
        var kubeClient kube.CLIClient
        var err error
@@ -61,5 +63,16 @@ func uninstall(cmd *cobra.Command, ctx cli.Context, rootArgs 
*RootArgs, uiArgs *
        if err != nil {
                return err
        }
-       // todo
+       objectsList, err := uninstall.GetPrunedResources(
+               vals.GetPathString("metadata.name"),
+               vals.GetPathString("metadata.namespace"),
+       )
+       if err != nil {
+               return err
+       }
+       if err := uninstall.DeleteObjectsList(kubeClient, rootArgs.DryRun, cl, 
objectsList); err != nil {
+               return fmt.Errorf("failed to delete control plane resources by 
revision: %v", err)
+       }
+       pl.SetState(progress.StateUninstallComplete)
+       return nil
 }
diff --git a/operator/pkg/install/installer.go 
b/operator/pkg/install/installer.go
index ab9b6869..782d8c71 100644
--- a/operator/pkg/install/installer.go
+++ b/operator/pkg/install/installer.go
@@ -133,7 +133,7 @@ func (i Installer) prune(manifests []manifest.ManifestSet) 
error {
                        excluded[mfs.Components].Insert(m.Hash())
                }
        }
-       return
+       return nil
 }
 
 var componentDependencies = map[component.Name][]component.Name{
diff --git a/operator/pkg/uninstall/uninstall.go 
b/operator/pkg/uninstall/uninstaller.go
similarity index 100%
rename from operator/pkg/uninstall/uninstall.go
rename to operator/pkg/uninstall/uninstaller.go

Reply via email to