From 41aedaa6876d5ef200928aafaec7c9d0b8a8a764 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 23 Aug 2025 11:04:24 -0700 Subject: 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 --- weed/shell/command_ec_common.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'weed/shell/command_ec_common.go') 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) +} -- cgit v1.2.3