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 c4d4bc0c [operator] add uninstall judgmental option
c4d4bc0c is described below

commit c4d4bc0cb3b8fdf3814d9ac1410e3da635368800
Author: mfordjody <[email protected]>
AuthorDate: Mon Dec 23 10:31:42 2024 +0800

    [operator] add uninstall judgmental option
---
 operator/cmd/cluster/install.go   |  3 +--
 operator/cmd/cluster/uninstall.go | 20 ++++++++++++++++----
 operator/pkg/values/map.go        | 11 +++++++++++
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/operator/cmd/cluster/install.go b/operator/cmd/cluster/install.go
index 2c1a966c..4f882737 100644
--- a/operator/cmd/cluster/install.go
+++ b/operator/cmd/cluster/install.go
@@ -49,7 +49,7 @@ func InstallCmdWithArgs(ctx cli.Context, rootArgs *RootArgs, 
iArgs *installArgs)
                Use:   "install",
                Short: "Applies an Dubbo manifest, installing or reconfiguring 
Dubbo on a cluster",
                Long:  "The install command generates an Dubbo install manifest 
and applies it to a cluster",
-               Example: `  # Apply a default dubboctl installation.
+               Example: ` # Apply a default dubboctl installation.
   dubboctl install
   
   # Apply a config file.
@@ -57,7 +57,6 @@ func InstallCmdWithArgs(ctx cli.Context, rootArgs *RootArgs, 
iArgs *installArgs)
   
   # Apply a default profile.
   dubboctl install --profile=demo
-
                `,
                Aliases: []string{"apply"},
                Args:    cobra.ExactArgs(0),
diff --git a/operator/cmd/cluster/uninstall.go 
b/operator/cmd/cluster/uninstall.go
index 18009a61..c405e89e 100644
--- a/operator/cmd/cluster/uninstall.go
+++ b/operator/cmd/cluster/uninstall.go
@@ -13,7 +13,8 @@ import (
 )
 
 const (
-       AllResourcesRemovedWarning = "All Dubbo resources will be pruned from 
the cluster\n"
+       AllResourcesRemovedWarning                  = "All Dubbo resources will 
be pruned from the cluster\n"
+       PurgeWithRevisionOrOperatorSpecifiedWarning = "Purge uninstall will 
remove all Dubbo resources, ignoring the specified revision or operator file"
 )
 
 type uninstallArgs struct {
@@ -37,14 +38,20 @@ func UninstallCmd(ctx cli.Context) *cobra.Command {
        uicmd := &cobra.Command{
                Use:   "uninstall",
                Short: "Uninstall Dubbo-related resources",
-               Long:  "Uninstalling Dubbo from the Cluster",
-               Example: `ยท# Uninstall a single control plane by dop file
+               Long:  "This uninstall command will uninstall the dubbo 
cluster",
+               Example: ` # Uninstall a single control plane by dop file
   dubboctl uninstall -f dop.yaml
   
   # Uninstall all control planes and shared resources
   dubboctl uninstall --purge`,
                Args: func(cmd *cobra.Command, args []string) error {
-                       return fmt.Errorf("at least one of the --filename or 
--purge flags must be set")
+                       if uiArgs.files == "" && !uiArgs.purge {
+                               return fmt.Errorf("at least one of the 
--filename or --purge flags must be set")
+                       }
+                       if len(args) > 0 {
+                               return fmt.Errorf("dubboctl uninstall does not 
take arguments")
+                       }
+                       return nil
                },
                RunE: func(cmd *cobra.Command, args []string) error {
                        return UnInstall(cmd, ctx, rootArgs, uiArgs)
@@ -59,10 +66,15 @@ func UnInstall(cmd *cobra.Command, ctx cli.Context, 
rootArgs *RootArgs, uiArgs *
        cl := clog.NewConsoleLogger(cmd.OutOrStdout(), cmd.ErrOrStderr(), 
installerScope)
        var kubeClient kube.CLIClient
        var err error
+
        if err != nil {
                return err
        }
+
        pl := progress.NewInfo()
+       if uiArgs.purge && uiArgs.files != "" {
+               cl.LogAndPrint(PurgeWithRevisionOrOperatorSpecifiedWarning)
+       }
        setFlags := applyFlagAliases(uiArgs.sets, uiArgs.manifestPath)
        files := []string{}
        if uiArgs.files != "" {
diff --git a/operator/pkg/values/map.go b/operator/pkg/values/map.go
index a691e24e..e36d4310 100644
--- a/operator/pkg/values/map.go
+++ b/operator/pkg/values/map.go
@@ -390,3 +390,14 @@ func extractKV(seg string) (string, string, bool) {
        sanitized := seg[1 : len(seg)-1]
        return strings.Cut(sanitized, ":")
 }
+
+func GetValueForSetFlag(setFlags []string, path string) string {
+       r := ""
+       for _, sf := range setFlags {
+               p, v := getPV(sf)
+               if p == path {
+                       r = v
+               }
+       }
+       return r
+}

Reply via email to