shell: spell the default-collection keyword via CollectionDefault

This commit is contained in:
Chris Lu
2026-10-16 20:25:09 -07:00
parent d1f2a5c487
commit 7d2a61b606
15 changed files with 23 additions and 22 deletions
+5 -4
View File
@@ -35,7 +35,7 @@ func (c *commandCollectionDelete) HasTag(CommandTag) bool {
func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
colDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
collectionName := colDeleteCommand.String("collection", "", "collection to delete. Use '_default' for the empty-named collection.")
collectionName := colDeleteCommand.String("collection", "", "collection to delete. Use '"+CollectionDefault+"' for the empty-named collection.")
applyBalancing := colDeleteCommand.Bool("apply", false, "apply the collection")
// TODO: remove this alias
applyBalancingAlias := colDeleteCommand.Bool("force", false, "apply the collection (alias for -apply)")
@@ -55,9 +55,10 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
return fmt.Errorf("empty collection name is not allowed")
}
// "_default_" stays accepted for compatibility; "_default" is the shared
// keyword every other -collection flag uses for the empty-named collection.
if *collectionName == "_default_" {
// The legacy "_default_" spelling stays accepted for compatibility;
// CollectionDefault is the shared keyword every other -collection flag
// uses for the empty-named collection.
if *collectionName == CollectionDefault+"_" {
*collectionName = ""
}
*collectionName = resolveCollectionName(*collectionName)
+1 -1
View File
@@ -44,7 +44,7 @@ func (c *commandEcBalance) HasTag(CommandTag) bool {
func (c *commandEcBalance) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
balanceCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
collection := balanceCommand.String("collection", "EACH_COLLECTION", "comma-separated collection names, wildcards, or regex patterns, \"_default\" for the collection with no name, or \"EACH_COLLECTION\" for each collection")
collection := balanceCommand.String("collection", string(wildcard.CollectionFilterEach), "comma-separated collection names, wildcards, or regex patterns, \""+CollectionDefault+"\" for the collection with no name, or \""+string(wildcard.CollectionFilterEach)+"\" for each collection")
dc := balanceCommand.String("dataCenter", "", "only apply the balancing for this dataCenter")
shardReplicaPlacement := balanceCommand.String("shardReplicaPlacement", "", "replica placement for EC shards, or master default if empty")
diskTypeStr := balanceCommand.String("diskType", "", "the disk type for EC shards (hdd, ssd, or empty for default hdd)")
+1 -1
View File
@@ -14,7 +14,7 @@ func TestCompileCollectionPattern(t *testing.T) {
{pattern: CollectionDefault, matches: []string{""}, misses: []string{"pictures"}},
{pattern: "pictures", matches: []string{"pictures"}, misses: []string{"", "pictures-backup"}},
{pattern: "pictures,videos", matches: []string{"pictures", "videos"}, misses: []string{"", "clips"}},
{pattern: "pictures,_default", matches: []string{"pictures", ""}, misses: []string{"clips"}},
{pattern: "pictures," + CollectionDefault, matches: []string{"pictures", ""}, misses: []string{"clips"}},
{pattern: "pictures*", matches: []string{"pictures", "pictures-backup"}, misses: []string{"clips"}},
{pattern: "^pictures", matches: []string{"pictures", "pictures-backup"}, misses: []string{"clips"}},
{pattern: "*", matches: []string{"", "pictures"}},
+1 -1
View File
@@ -62,7 +62,7 @@ func (c *commandEcEncode) Help() string {
- Several collections: ec.encode -collection="mybucket,otherbucket"
- Match by prefix: ec.encode -collection="bucket*"
- Match all collections: ec.encode -collection="*"
- The empty-named collection: ec.encode -collection="_default"
- The empty-named collection: ec.encode -collection="` + CollectionDefault + `"
Options:
-verbose: show detailed reasons why volumes are not selected for encoding
+1 -1
View File
@@ -74,7 +74,7 @@ func (c *commandEcRebuild) HasTag(CommandTag) bool {
func (c *commandEcRebuild) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
fixCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
collection := fixCommand.String("collection", "EACH_COLLECTION", "comma-separated collection names, wildcards, or regex patterns, \"_default\" for the collection with no name, or \"EACH_COLLECTION\" for each collection")
collection := fixCommand.String("collection", string(wildcard.CollectionFilterEach), "comma-separated collection names, wildcards, or regex patterns, \""+CollectionDefault+"\" for the collection with no name, or \""+string(wildcard.CollectionFilterEach)+"\" for each collection")
volumeIdsStr := fixCommand.String("volumeIds", "", "optional comma-separated list of volume ID to process; defaults to all volumes in the collection")
maxParallelization := fixCommand.Int("maxParallelization", DefaultMaxParallelization, "run up to X tasks in parallel, whenever possible")
applyChanges := fixCommand.Bool("apply", false, "apply the changes")
+1 -1
View File
@@ -63,7 +63,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
fsConfigureCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
locationPrefix := fsConfigureCommand.String("locationPrefix", "", "path prefix, required to update the path-specific configuration")
collection := fsConfigureCommand.String("collection", "", "assign writes to this collection; \"_default\" for the collection with no name")
collection := fsConfigureCommand.String("collection", "", "assign writes to this collection; \""+CollectionDefault+"\" for the collection with no name")
replication := fsConfigureCommand.String("replication", "", "assign writes with this replication")
ttl := fsConfigureCommand.String("ttl", "", "assign writes with this ttl (e.g., 1m, 1h, 1d, 1w, 1y)")
diskType := fsConfigureCommand.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
+1 -1
View File
@@ -67,7 +67,7 @@ func (c *commandFsMergeVolumes) Do(args []string, commandEnv *CommandEnv, writer
dirArg := fsMergeVolumesCommand.String("dir", "/", "base directory to find and update files")
fromVolumeArg := fsMergeVolumesCommand.Uint("fromVolumeId", 0, "move chunks with this volume id")
toVolumeArg := fsMergeVolumesCommand.String("toVolumeId", "", "change chunks to this volume id, or distribute across a comma-separated list of volume ids")
collectionArg := fsMergeVolumesCommand.String("collection", "*", "comma-separated collection names, wildcards, or regex patterns; \"_default\" for the collection with no name")
collectionArg := fsMergeVolumesCommand.String("collection", "*", "comma-separated collection names, wildcards, or regex patterns; \""+CollectionDefault+"\" for the collection with no name")
apply := fsMergeVolumesCommand.Bool("apply", false, "applying the metadata changes")
if err = fsMergeVolumesCommand.Parse(args); err != nil {
return err
+2 -2
View File
@@ -246,9 +246,9 @@ func TestCreateMergePlan_CollectionFilter(t *testing.T) {
}
// "_default" merges only the unnamed-collection volumes.
plan, err := newCmd().createMergePlan("_default", nil, 0)
plan, err := newCmd().createMergePlan(CollectionDefault, nil, 0)
if err != nil {
t.Fatalf("_default: %v", err)
t.Fatalf("%s: %v", CollectionDefault, err)
}
if got := plan.targets[needle.VolumeId(1)]; len(got) != 1 || got[0] != needle.VolumeId(2) {
t.Fatalf("expected 1->2, got %v", plan.targets)
+1 -1
View File
@@ -46,7 +46,7 @@ func (c *commandMqTopicCompact) Do(args []string, commandEnv *CommandEnv, writer
topicName := mqCommand.String("topic", "", "topic name")
timeAgo := mqCommand.Duration("timeAgo", 2*time.Minute, "start time before now. \"300ms\", \"1.5h\" or \"2h45m\". Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"")
replication := mqCommand.String("replication", "", "replication type")
collection := mqCommand.String("collection", "", "optional collection name; \"_default\" for the collection with no name")
collection := mqCommand.String("collection", "", "optional collection name; \""+CollectionDefault+"\" for the collection with no name")
dataCenter := mqCommand.String("dataCenter", "", "optional data center name")
diskType := mqCommand.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
maxMB := mqCommand.Int("maxMB", 4, "split files larger than the limit")
+1 -1
View File
@@ -111,7 +111,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io.
c.verbose = fsckCommand.Bool("v", false, "verbose mode")
c.skipEcVolumes = fsckCommand.Bool("skipEcVolumes", false, "skip erasure coded volumes")
c.findMissingChunksInFiler = fsckCommand.Bool("findMissingChunksInFiler", false, "see \"help volume.fsck\"")
c.collection = fsckCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; empty or \"*\" matches all, \"_default\" the collection with no name")
c.collection = fsckCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; empty or \"*\" matches all, \""+CollectionDefault+"\" the collection with no name")
volumeIds := fsckCommand.String("volumeId", "", "comma separated the volume id")
applyPurging := fsckCommand.Bool("reallyDeleteFromVolume", false, "<expert only!> after detection, delete missing data from volumes / delete missing file entries from filer. Currently this only works with default filerGroup.")
c.forcePurging = fsckCommand.Bool("forcePurging", false, "delete missing data from volumes in one replica used together with applyPurging")
+1 -1
View File
@@ -39,7 +39,7 @@ func (c *commandGrow) Do(args []string, commandEnv *CommandEnv, writer io.Writer
volumeVacuumCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
growCount := volumeVacuumCommand.Uint("count", 2, "")
collection := volumeVacuumCommand.String("collection", "", "grow this collection; \"_default\" for the collection with no name")
collection := volumeVacuumCommand.String("collection", "", "grow this collection; \""+CollectionDefault+"\" for the collection with no name")
dataCenter := volumeVacuumCommand.String("dataCenter", "", "grow volumes only from the specified data center")
rack := volumeVacuumCommand.String("rack", "", "grow volumes only from the specified rack")
dataNode := volumeVacuumCommand.String("dataNode", "", "grow volumes only from the specified data node")
+1 -1
View File
@@ -48,7 +48,7 @@ func (c *commandVolumeMark) Do(args []string, commandEnv *CommandEnv, writer io.
volMarkCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
volumeIdInt := volMarkCommand.Int("volumeId", 0, "the volume id")
nodeStr := volMarkCommand.String("node", "", "the volume server <host>:<port>")
collection := volMarkCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; \"_default\" for the collection with no name")
collection := volMarkCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; \""+CollectionDefault+"\" for the collection with no name")
writable := volMarkCommand.Bool("writable", false, "volume mark writable")
readonly := volMarkCommand.Bool("readonly", false, "volume mark readonly")
readonlyCanDelete := volMarkCommand.Bool("readonlyCanDelete", false, "volume mark readonly but still accepting deletes")
+1 -1
View File
@@ -67,7 +67,7 @@ func (c *commandVolumeTierMove) Help() string {
Note:
-collectionPattern is a comma-separated list of collection names, with "*" and "?"
wildcards, and regex patterns. Use "_default" to match only the default collection
wildcards, and regex patterns. Use "` + CollectionDefault + `" to match only the default collection
(volumes with no collection name). An empty pattern matches all collections.
`
+1 -1
View File
@@ -44,7 +44,7 @@ func (c *commandVacuum) Do(args []string, commandEnv *CommandEnv, writer io.Writ
volumeVacuumCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
garbageThreshold := volumeVacuumCommand.Float64("garbageThreshold", 0.3, "vacuum when garbage is more than this limit")
collection := volumeVacuumCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; empty or \"*\" matches all, \"_default\" the collection with no name")
collection := volumeVacuumCommand.String("collection", "", "comma-separated collection names, wildcards, or regex patterns; empty or \"*\" matches all, \""+CollectionDefault+"\" the collection with no name")
volumeIds := volumeVacuumCommand.String("volumeId", "", "comma-separated list of volume IDs")
if err = volumeVacuumCommand.Parse(args); err != nil {
return nil
+4 -4
View File
@@ -108,12 +108,12 @@ func TestVacuumRequestsForPattern(t *testing.T) {
// The unnamed collection resolves to per-volume requests — no Collection
// value selects it alone, and read-only volumes stay skipped.
reqs, err = vacuumRequestsForPattern(topo, mustMatcher(t, "_default"))
reqs, err = vacuumRequestsForPattern(topo, mustMatcher(t, CollectionDefault))
if err != nil {
t.Fatalf("_default: %v", err)
t.Fatalf("%s: %v", CollectionDefault, err)
}
if len(reqs) != 1 || reqs[0].VolumeId != 2 || reqs[0].Collection != "" {
t.Fatalf("_default: got %v, want one per-volume request for volume 2", reqs)
t.Fatalf("%s: got %v, want one per-volume request for volume 2", CollectionDefault, reqs)
}
// A filter hitting nothing is an error, not a silent no-op.
@@ -140,7 +140,7 @@ func TestVacuumRequestsForVolumeIds(t *testing.T) {
}
// The unnamed collection sends a volume-id-only request.
reqs, err = vacuumRequestsForVolumeIds(topo, mustMatcher(t, "_default"), []uint32{2})
reqs, err = vacuumRequestsForVolumeIds(topo, mustMatcher(t, CollectionDefault), []uint32{2})
if err != nil {
t.Fatalf("vid 2 in default: %v", err)
}