diff options
| author | Lisandro Pin <lisandro.pin@proton.ch> | 2025-11-10 04:58:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-09 19:58:38 -0800 |
| commit | 76e4a519646a60c612956d197652359b1d4ba477 (patch) | |
| tree | 37de583f5f6e79936bc137afe6e6d4b12e6065a5 /weed/shell/command_fs_meta_change_volume_id.go | |
| parent | 2a05af2e14741540cad00a410f8e851f863628c7 (diff) | |
| download | seaweedfs-76e4a519646a60c612956d197652359b1d4ba477.tar.xz seaweedfs-76e4a519646a60c612956d197652359b1d4ba477.zip | |
Unify the parameter to disable dry-run on weed shell commands to `-apply` (instead of `-force`). (#7450)
* Unify the parameter to disable dry-run on weed shell commands to --apply (instead of --force).
* lint
* refactor
* Execution Order Corrected
* handle deprecated force flag
* fix help messages
* Refactoring]: Using flag.FlagSet.Visit()
* consistent with other commands
* Checks for both flags
* fix toml files
---------
Co-authored-by: chrislu <chris.lu@gmail.com>
Diffstat (limited to 'weed/shell/command_fs_meta_change_volume_id.go')
| -rw-r--r-- | weed/shell/command_fs_meta_change_volume_id.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/weed/shell/command_fs_meta_change_volume_id.go b/weed/shell/command_fs_meta_change_volume_id.go index 167d64288..ec7cba729 100644 --- a/weed/shell/command_fs_meta_change_volume_id.go +++ b/weed/shell/command_fs_meta_change_volume_id.go @@ -4,13 +4,14 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "github.com/seaweedfs/seaweedfs/weed/storage/needle" - "github.com/seaweedfs/seaweedfs/weed/util" "io" "os" "strconv" "strings" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/storage/needle" + "github.com/seaweedfs/seaweedfs/weed/util" ) func init() { @@ -27,8 +28,8 @@ func (c *commandFsMetaChangeVolumeId) Name() string { func (c *commandFsMetaChangeVolumeId) Help() string { return `change volume id in existing metadata. - fs.meta.changeVolumeId -dir=/path/to/a/dir -fromVolumeId=x -toVolumeId=y -force - fs.meta.changeVolumeId -dir=/path/to/a/dir -mapping=/path/to/mapping/file -force + fs.meta.changeVolumeId -dir=/path/to/a/dir -fromVolumeId=x -toVolumeId=y -apply + fs.meta.changeVolumeId -dir=/path/to/a/dir -mapping=/path/to/mapping/file -apply The mapping file should have these lines, each line is: [fromVolumeId]=>[toVolumeId] e.g. @@ -49,11 +50,16 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv, mappingFileName := fsMetaChangeVolumeIdCommand.String("mapping", "", "a file with multiple volume id changes, with each line as x=>y") fromVolumeId := fsMetaChangeVolumeIdCommand.Uint("fromVolumeId", 0, "change metadata with this volume id") toVolumeId := fsMetaChangeVolumeIdCommand.Uint("toVolumeId", 0, "change metadata to this volume id") - isForce := fsMetaChangeVolumeIdCommand.Bool("force", false, "applying the metadata changes") + applyChanges := fsMetaChangeVolumeIdCommand.Bool("apply", false, "apply the metadata changes") + // TODO: remove this alias + applyChangesAlias := fsMetaChangeVolumeIdCommand.Bool("force", false, "apply the metadata changes (alias for -apply)") if err = fsMetaChangeVolumeIdCommand.Parse(args); err != nil { return err } + handleDeprecatedForceFlag(writer, fsMetaChangeVolumeIdCommand, applyChangesAlias, applyChanges) + infoAboutSimulationMode(writer, *applyChanges, "-apply") + // load the mapping mapping := make(map[needle.VolumeId]needle.VolumeId) if *mappingFileName != "" { @@ -86,7 +92,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv, } if hasChanges { println("Updating", parentPath, entry.Name) - if *isForce { + if *applyChanges { if updateErr := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{ Directory: string(parentPath), Entry: entry, |
