Skip to content

Commit 29ed4d3

Browse files
authored
fix: delete all buckets with storage rm (#3853)
1 parent 3c96a2b commit 29ed4d3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cmd/storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ cp -r ss:///bucket/docs .
7070
Example: `rm -r ss:///bucket/docs
7171
rm ss:///bucket/docs/example.md ss:///bucket/readme.md
7272
`,
73-
Args: cobra.MinimumNArgs(1),
7473
RunE: func(cmd *cobra.Command, args []string) error {
7574
return rm.Run(cmd.Context(), args, recursive, afero.NewOsFs())
7675
},

internal/storage/rm/rm.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,22 @@ func Run(ctx context.Context, paths []string, recursive bool, fsys afero.Fs) err
4949
if err != nil {
5050
return err
5151
}
52+
if len(groups) == 0 {
53+
if !recursive {
54+
return errors.New(errMissingFlag)
55+
}
56+
buckets, err := api.ListBuckets(ctx)
57+
if err != nil {
58+
return err
59+
}
60+
for _, b := range buckets {
61+
groups[b.Name] = []string{""}
62+
}
63+
}
64+
console := utils.NewConsole()
5265
for bucket, prefixes := range groups {
5366
confirm := fmt.Sprintf("Confirm deleting files in bucket %v?", utils.Bold(bucket))
54-
if shouldDelete, err := utils.NewConsole().PromptYesNo(ctx, confirm, false); err != nil {
67+
if shouldDelete, err := console.PromptYesNo(ctx, confirm, false); err != nil {
5568
return err
5669
} else if !shouldDelete {
5770
continue

0 commit comments

Comments
 (0)