diff --git a/weed/shell/command_collection_delete.go b/weed/shell/command_collection_delete.go index 545e7830b2..f80c3d9a52 100644 --- a/weed/shell/command_collection_delete.go +++ b/weed/shell/command_collection_delete.go @@ -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) diff --git a/weed/shell/command_ec_balance.go b/weed/shell/command_ec_balance.go index f50bcfe5c3..7dcd4b0d24 100644 --- a/weed/shell/command_ec_balance.go +++ b/weed/shell/command_ec_balance.go @@ -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)") diff --git a/weed/shell/command_ec_common_test.go b/weed/shell/command_ec_common_test.go index a447800817..22a0c1a1a7 100644 --- a/weed/shell/command_ec_common_test.go +++ b/weed/shell/command_ec_common_test.go @@ -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"}}, diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go index 7ae07cfcf3..0effe470ab 100644 --- a/weed/shell/command_ec_encode.go +++ b/weed/shell/command_ec_encode.go @@ -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 diff --git a/weed/shell/command_ec_rebuild.go b/weed/shell/command_ec_rebuild.go index 24dfc7af69..9aec3c6ccd 100644 --- a/weed/shell/command_ec_rebuild.go +++ b/weed/shell/command_ec_rebuild.go @@ -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") diff --git a/weed/shell/command_fs_configure.go b/weed/shell/command_fs_configure.go index 56bbd5f375..a186ae428c 100644 --- a/weed/shell/command_fs_configure.go +++ b/weed/shell/command_fs_configure.go @@ -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|] hard drive or solid state drive or any tag") diff --git a/weed/shell/command_fs_merge_volumes.go b/weed/shell/command_fs_merge_volumes.go index f12ada3add..99b6140943 100644 --- a/weed/shell/command_fs_merge_volumes.go +++ b/weed/shell/command_fs_merge_volumes.go @@ -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 diff --git a/weed/shell/command_fs_merge_volumes_test.go b/weed/shell/command_fs_merge_volumes_test.go index f7ed2725a8..d02dd60b71 100644 --- a/weed/shell/command_fs_merge_volumes_test.go +++ b/weed/shell/command_fs_merge_volumes_test.go @@ -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) diff --git a/weed/shell/command_mq_topic_compact.go b/weed/shell/command_mq_topic_compact.go index 3ade80c154..87c324a036 100644 --- a/weed/shell/command_mq_topic_compact.go +++ b/weed/shell/command_mq_topic_compact.go @@ -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|] hard drive or solid state drive or any tag") maxMB := mqCommand.Int("maxMB", 4, "split files larger than the limit") diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go index 6bc74dd47e..f62a491e1f 100644 --- a/weed/shell/command_volume_fsck.go +++ b/weed/shell/command_volume_fsck.go @@ -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, " 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") diff --git a/weed/shell/command_volume_grow.go b/weed/shell/command_volume_grow.go index 20b4f2f27e..b1f11d8694 100644 --- a/weed/shell/command_volume_grow.go +++ b/weed/shell/command_volume_grow.go @@ -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") diff --git a/weed/shell/command_volume_mark.go b/weed/shell/command_volume_mark.go index 5d0f2f0ee7..443a7a943a 100644 --- a/weed/shell/command_volume_mark.go +++ b/weed/shell/command_volume_mark.go @@ -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 :") - 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") diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go index 0d0ac97be2..11a8481a9a 100644 --- a/weed/shell/command_volume_tier_move.go +++ b/weed/shell/command_volume_tier_move.go @@ -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. ` diff --git a/weed/shell/command_volume_vacuum.go b/weed/shell/command_volume_vacuum.go index e162b161cd..f047116d91 100644 --- a/weed/shell/command_volume_vacuum.go +++ b/weed/shell/command_volume_vacuum.go @@ -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 diff --git a/weed/shell/command_volume_vacuum_test.go b/weed/shell/command_volume_vacuum_test.go index 608623169e..a8ec288646 100644 --- a/weed/shell/command_volume_vacuum_test.go +++ b/weed/shell/command_volume_vacuum_test.go @@ -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) }