Browse Source

refactor

pull/7450/head
chrislu 2 months ago
parent
commit
8724942779
  1. 6
      weed/shell/command_collection_delete.go
  2. 5
      weed/shell/command_ec_balance.go
  3. 5
      weed/shell/command_ec_rebuild.go
  4. 12
      weed/shell/command_fs_configure.go
  5. 5
      weed/shell/command_fs_meta_change_volume_id.go
  6. 5
      weed/shell/command_volume_balance.go
  7. 5
      weed/shell/command_volume_check_disk.go
  8. 6
      weed/shell/command_volume_delete_empty.go
  9. 5
      weed/shell/command_volume_fix_replication.go
  10. 5
      weed/shell/command_volume_server_evacuate.go
  11. 5
      weed/shell/command_volume_tier_move.go

6
weed/shell/command_collection_delete.go

@ -49,10 +49,8 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
return
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyBalancing = *applyBalancingAlias
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
if *collectionName == "" {
return fmt.Errorf("empty collection name is not allowed")
}

5
weed/shell/command_ec_balance.go

@ -49,10 +49,7 @@ func (c *commandEcBalance) Do(args []string, commandEnv *CommandEnv, writer io.W
return
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyBalancing = *applyBalancingAlias
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
var collections []string
if *collection == "EACH_COLLECTION" {

5
weed/shell/command_ec_rebuild.go

@ -75,10 +75,7 @@ func (c *commandEcRebuild) Do(args []string, commandEnv *CommandEnv, writer io.W
return
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChanges = *applyChangesAlias
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
// collect all ec nodes
allEcNodes, _, err := collectEcNodes(commandEnv)

12
weed/shell/command_fs_configure.go

@ -159,3 +159,15 @@ func infoAboutSimulationMode(writer io.Writer, forceMode bool, forceModeOption s
}
fmt.Fprintf(writer, "Running in simulation mode. Use \"%s\" option to apply the changes.\n", forceModeOption)
}
// handleDeprecatedForceFlag handles the deprecated -force flag by checking if it's set,
// printing a deprecation warning, and copying its value to the new flag.
// Returns true if the deprecated flag was used.
func handleDeprecatedForceFlag(writer io.Writer, forceAlias *bool, applyFlag *bool) bool {
if *forceAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyFlag = *forceAlias
return true
}
return false
}

5
weed/shell/command_fs_meta_change_volume_id.go

@ -57,10 +57,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv,
return err
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChanges = *applyChangesAlias
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
// load the mapping
mapping := make(map[needle.VolumeId]needle.VolumeId)

5
weed/shell/command_volume_balance.go

@ -98,10 +98,7 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer
if err = balanceCommand.Parse(args); err != nil {
return nil
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyBalancing = *applyBalancingAlias
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
c.writable = *writable
c.applyBalancing = *applyBalancing

5
weed/shell/command_volume_check_disk.go

@ -134,10 +134,7 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
return
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChanges = *applyChangesAlias
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
c.env = commandEnv
c.writer = writer

6
weed/shell/command_volume_delete_empty.go

@ -2,7 +2,6 @@ package shell
import (
"flag"
"fmt"
"io"
"log"
"time"
@ -53,10 +52,7 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyBalancing = *applyBalancingAlias
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
// collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)

5
weed/shell/command_volume_fix_replication.go

@ -80,10 +80,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
}
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChanges = *applyChangesAlias
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
commandEnv.noLock = !*applyChanges
if err = commandEnv.confirmIsLocked(args); *applyChanges && err != nil {

5
weed/shell/command_volume_server_evacuate.go

@ -71,10 +71,7 @@ func (c *commandVolumeServerEvacuate) Do(args []string, commandEnv *CommandEnv,
return
}
if *applyChangeAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChange = *applyChangeAlias
}
handleDeprecatedForceFlag(writer, applyChangeAlias, applyChange)
if *volumeServer == "" && *c.volumeRack == "" {
return fmt.Errorf("need to specify volume server by -node=<host>:<port> or source rack")
}

5
weed/shell/command_volume_tier_move.go

@ -81,10 +81,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
return
}
if *applyChangeAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyChange = *applyChangeAlias
}
handleDeprecatedForceFlag(writer, applyChangeAlias, applyChange)
fromDiskType := types.ToDiskType(*source)
toDiskType := types.ToDiskType(*target)

Loading…
Cancel
Save