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

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new 496abb887 Add flags to group delete command for force, dry-run, and 
data-only options (#1009)
496abb887 is described below

commit 496abb887af2252a927a88c1abb34c22b42c1952
Author: Huang Youliang <[email protected]>
AuthorDate: Thu Mar 19 17:34:52 2026 +0800

    Add flags to group delete command for force, dry-run, and data-only options 
(#1009)
    
    * Add flags to group delete command for force, dry-run, and data-only 
options
    
    * Update CHANGES.md
    
    ---------
    
    Co-authored-by: Gao Hongtao <[email protected]>
---
 CHANGES.md                         |  1 +
 bydbctl/internal/cmd/group.go      | 20 +++++++++++++++++---
 bydbctl/internal/cmd/group_test.go | 12 ++++++++++++
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 76c802462..8c2ec60c3 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -28,6 +28,7 @@ Release Notes.
 - Support relative paths in configuration.
 - Support 'none' node discovery and make it the default.
 - Support server-side element ID generation for stream writes when clients 
omit element_id.
+- Implement entire group deletion.
 
 ### Bug Fixes
 
diff --git a/bydbctl/internal/cmd/group.go b/bydbctl/internal/cmd/group.go
index 412c757de..c83366f4c 100644
--- a/bydbctl/internal/cmd/group.go
+++ b/bydbctl/internal/cmd/group.go
@@ -106,21 +106,35 @@ func newGroupCmd() *cobra.Command {
                },
        }
 
+       var force, dryRun, dataOnly bool
        deleteCmd := &cobra.Command{
-               Use:     "delete [-g group]",
+               Use:     "delete [-g group] [--force] [--dry-run] 
[--data-only]",
                Version: version.Build(),
                Short:   "Delete a group",
                RunE: func(_ *cobra.Command, _ []string) (err error) {
                        return rest(parseFromFlags, func(request request) 
(*resty.Response, error) {
-                               return request.req.SetPathParam("group", 
request.group).Delete(getPath("/api/v1/group/schema/{group}"))
+                               return request.req.
+                                       SetPathParam("group", request.group).
+                                       SetQueryParam("force", 
fmt.Sprintf("%v", force)).
+                                       SetQueryParam("dry_run", 
fmt.Sprintf("%v", dryRun)).
+                                       SetQueryParam("data_only", 
fmt.Sprintf("%v", dataOnly)).
+                                       
Delete(getPath("/api/v1/group/schema/{group}"))
                        },
-                               func(_ int, reqBody reqBody, _ []byte) error {
+                               func(_ int, reqBody reqBody, respBody []byte) 
error {
+                                       if dryRun {
+                                               fmt.Printf("group %s dry-run 
deletion result:", reqBody.group)
+                                               fmt.Println()
+                                               return yamlPrinter(0, reqBody, 
respBody)
+                                       }
                                        fmt.Printf("group %s is deleted", 
reqBody.group)
                                        fmt.Println()
                                        return nil
                                }, enableTLS, insecure, cert)
                },
        }
+       deleteCmd.Flags().BoolVarP(&force, "force", "", false, "Force delete 
the group even if it contains data")
+       deleteCmd.Flags().BoolVarP(&dryRun, "dry-run", "", false, "Preview what 
would be deleted without making changes")
+       deleteCmd.Flags().BoolVarP(&dataOnly, "data-only", "", false, "Delete 
only data files without removing metadata")
 
        listCmd := &cobra.Command{
                Use:     "list",
diff --git a/bydbctl/internal/cmd/group_test.go 
b/bydbctl/internal/cmd/group_test.go
index ceac5023e..34344d708 100644
--- a/bydbctl/internal/cmd/group_test.go
+++ b/bydbctl/internal/cmd/group_test.go
@@ -105,6 +105,18 @@ resource_opts:
                }).Should(Succeed())
        })
 
+       It("delete group with dry-run flag", func() {
+               rootCmd.SetArgs([]string{"group", "delete", "-g", "group1", 
"--dry-run"})
+               out := capturer.CaptureStdout(func() {
+                       err := rootCmd.Execute()
+                       Expect(err).NotTo(HaveOccurred())
+               })
+               Expect(out).To(ContainSubstring("group group1 dry-run deletion 
result:"))
+               resp := new(databasev1.GroupRegistryServiceDeleteResponse)
+               helpers.UnmarshalYAML([]byte(out[strings.Index(out, "\n")+1:]), 
resp)
+               Expect(resp).NotTo(BeNil())
+       })
+
        It("list group", func() {
                // create another group for list operation
                rootCmd.SetArgs([]string{"group", "create", "-f", "-"})

Reply via email to