Browse Source

handle deprecated force flag

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

2
weed/shell/command_collection_delete.go

@ -44,7 +44,7 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
return nil
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
handleDeprecatedForceFlag(writer, args, applyBalancingAlias, applyBalancing)
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

2
weed/shell/command_ec_balance.go

@ -44,7 +44,7 @@ func (c *commandEcBalance) Do(args []string, commandEnv *CommandEnv, writer io.W
return nil
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
handleDeprecatedForceFlag(writer, args, applyBalancingAlias, applyBalancing)
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

2
weed/shell/command_ec_rebuild.go

@ -70,7 +70,7 @@ func (c *commandEcRebuild) Do(args []string, commandEnv *CommandEnv, writer io.W
return nil
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
handleDeprecatedForceFlag(writer, args, applyChangesAlias, applyChanges)
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

16
weed/shell/command_fs_configure.go

@ -160,11 +160,19 @@ 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.
// handleDeprecatedForceFlag handles the deprecated -force flag by checking if it was
// explicitly provided (in any form), printing a deprecation warning, and copying its
// value to the new flag. This ensures that explicit -force=false takes precedence.
// Returns true if the deprecated flag was used.
func handleDeprecatedForceFlag(writer io.Writer, forceAlias *bool, applyFlag *bool) bool {
if *forceAlias != false {
func handleDeprecatedForceFlag(writer io.Writer, args []string, forceAlias *bool, applyFlag *bool) bool {
forceIsSet := false
for _, arg := range args {
if arg == "-force" || strings.HasPrefix(arg, "-force=") {
forceIsSet = true
break
}
}
if forceIsSet {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead\n")
*applyFlag = *forceAlias
return true

2
weed/shell/command_fs_meta_change_volume_id.go

@ -57,7 +57,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv,
return err
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
handleDeprecatedForceFlag(writer, args, applyChangesAlias, applyChanges)
// load the mapping
mapping := make(map[needle.VolumeId]needle.VolumeId)

2
weed/shell/command_volume_balance.go

@ -98,7 +98,7 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer
if err = balanceCommand.Parse(args); err != nil {
return nil
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
handleDeprecatedForceFlag(writer, args, applyBalancingAlias, applyBalancing)
c.writable = *writable
c.applyBalancing = *applyBalancing

2
weed/shell/command_volume_check_disk.go

@ -129,7 +129,7 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
return nil
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
handleDeprecatedForceFlag(writer, args, applyChangesAlias, applyChanges)
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

2
weed/shell/command_volume_delete_empty.go

@ -48,7 +48,7 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
return nil
}
handleDeprecatedForceFlag(writer, applyBalancingAlias, applyBalancing)
handleDeprecatedForceFlag(writer, args, applyBalancingAlias, applyBalancing)
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

2
weed/shell/command_volume_fix_replication.go

@ -79,7 +79,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
return nil
}
handleDeprecatedForceFlag(writer, applyChangesAlias, applyChanges)
handleDeprecatedForceFlag(writer, args, applyChangesAlias, applyChanges)
infoAboutSimulationMode(writer, *applyChanges, "-apply")
commandEnv.noLock = !*applyChanges

2
weed/shell/command_volume_server_evacuate.go

@ -66,7 +66,7 @@ func (c *commandVolumeServerEvacuate) Do(args []string, commandEnv *CommandEnv,
return nil
}
handleDeprecatedForceFlag(writer, applyChangeAlias, applyChange)
handleDeprecatedForceFlag(writer, args, applyChangeAlias, applyChange)
infoAboutSimulationMode(writer, *applyChange, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil && *applyChange {

2
weed/shell/command_volume_tier_move.go

@ -76,7 +76,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
return nil
}
handleDeprecatedForceFlag(writer, applyChangeAlias, applyChange)
handleDeprecatedForceFlag(writer, args, applyChangeAlias, applyChange)
infoAboutSimulationMode(writer, *applyChange, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {

Loading…
Cancel
Save