mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add range flag for delete in etcdctl
This commit is contained in:
parent
b99ba06eb3
commit
657a197bfa
@ -12,6 +12,7 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).
|
|||||||
|
|
||||||
- `etcd` will no longer start on data dir created by newer versions (for example etcd v3.6 will not run on v3.7+ data dir). To downgrade data dir please check out `etcdutl migrate` command.
|
- `etcd` will no longer start on data dir created by newer versions (for example etcd v3.6 will not run on v3.7+ data dir). To downgrade data dir please check out `etcdutl migrate` command.
|
||||||
- `etcd` doesn't support serving client requests on the peer listen endpoints (--listen-peer-urls). See [pull/13565](https://github.com/etcd-io/etcd/pull/13565).
|
- `etcd` doesn't support serving client requests on the peer listen endpoints (--listen-peer-urls). See [pull/13565](https://github.com/etcd-io/etcd/pull/13565).
|
||||||
|
- `etcdctl` will sleep(2s) in case of range delete without `--range` flag.See [pull/13747](https://github.com/etcd-io/etcd/pull/13747)
|
||||||
|
|
||||||
### Deprecations
|
### Deprecations
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.etcd.io/etcd/client/v3"
|
"go.etcd.io/etcd/client/v3"
|
||||||
@ -26,6 +28,7 @@ var (
|
|||||||
delPrefix bool
|
delPrefix bool
|
||||||
delPrevKV bool
|
delPrevKV bool
|
||||||
delFromKey bool
|
delFromKey bool
|
||||||
|
delRange bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDelCommand returns the cobra command for "del".
|
// NewDelCommand returns the cobra command for "del".
|
||||||
@ -39,6 +42,7 @@ func NewDelCommand() *cobra.Command {
|
|||||||
cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matching prefix")
|
cmd.Flags().BoolVar(&delPrefix, "prefix", false, "delete keys with matching prefix")
|
||||||
cmd.Flags().BoolVar(&delPrevKV, "prev-kv", false, "return deleted key-value pairs")
|
cmd.Flags().BoolVar(&delPrevKV, "prev-kv", false, "return deleted key-value pairs")
|
||||||
cmd.Flags().BoolVar(&delFromKey, "from-key", false, "delete keys that are greater than or equal to the given key using byte compare")
|
cmd.Flags().BoolVar(&delFromKey, "from-key", false, "delete keys that are greater than or equal to the given key using byte compare")
|
||||||
|
cmd.Flags().BoolVar(&delRange, "range", false, "delete range of keys")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +74,11 @@ func getDelOp(args []string) (string, []clientv3.OpOption) {
|
|||||||
cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set"))
|
cobrautl.ExitWithError(cobrautl.ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set"))
|
||||||
}
|
}
|
||||||
opts = append(opts, clientv3.WithRange(args[1]))
|
opts = append(opts, clientv3.WithRange(args[1]))
|
||||||
|
if !delRange {
|
||||||
|
fmt.Fprintf(os.Stderr, "Warning: Keys between %q and %q will be deleted. Please interrupt the command within next 2 seconds to cancel. "+
|
||||||
|
"You can provide `--range` flag to avoid the delay.\n", args[0], args[1])
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if delPrefix {
|
if delPrefix {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user