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
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user