aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-08-23 11:04:24 -0700
committerGitHub <noreply@github.com>2025-08-23 11:04:24 -0700
commit41aedaa6876d5ef200928aafaec7c9d0b8a8a764 (patch)
treee194f1666b7d467dc17bd045ab79c735ad1cdc05 /weed/shell/command_ec_common.go
parenta367c39967cc41179b72ea0674b663cefd95ec0b (diff)
downloadseaweedfs-41aedaa6876d5ef200928aafaec7c9d0b8a8a764.tar.xz
seaweedfs-41aedaa6876d5ef200928aafaec7c9d0b8a8a764.zip
Shell: support regular expression for collection selection (#7158)
* support regular expression for collection selection * refactor * ordering * fix exact match * Update command_volume_balance_test.go * simplify * Update command_volume_balance.go * comment
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index 8bef78394..665daa1b8 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/rand/v2"
+ "regexp"
"slices"
"sort"
"time"
@@ -1054,3 +1055,13 @@ func EcBalance(commandEnv *CommandEnv, collections []string, dc string, ecReplic
return nil
}
+
+// compileCollectionPattern compiles a regex pattern for collection matching.
+// Empty patterns match empty collections only.
+func compileCollectionPattern(pattern string) (*regexp.Regexp, error) {
+ if pattern == "" {
+ // empty pattern matches empty collection
+ return regexp.Compile("^$")
+ }
+ return regexp.Compile(pattern)
+}