etcdctlv3: consolidate dial code; use clientv3
This commit is contained in:
@ -19,7 +19,6 @@ import (
|
||||
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
|
||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
)
|
||||
|
||||
@ -44,19 +43,8 @@ func deleteRangeCommandFunc(cmd *cobra.Command, args []string) {
|
||||
rangeEnd = []byte(args[1])
|
||||
}
|
||||
|
||||
endpoint, err := cmd.Flags().GetString("endpoint")
|
||||
if err != nil {
|
||||
ExitWithError(ExitError, err)
|
||||
}
|
||||
// TODO: enable grpc.WithTransportCredentials(creds)
|
||||
conn, err := grpc.Dial(endpoint, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
ExitWithError(ExitBadConnection, err)
|
||||
}
|
||||
kv := pb.NewKVClient(conn)
|
||||
req := &pb.DeleteRangeRequest{Key: key, RangeEnd: rangeEnd}
|
||||
|
||||
kv.DeleteRange(context.Background(), req)
|
||||
mustClient(cmd).KV.DeleteRange(context.Background(), req)
|
||||
|
||||
if rangeEnd != nil {
|
||||
fmt.Printf("range [%s, %s) is deleted\n", string(key), string(rangeEnd))
|
||||
|
Reference in New Issue
Block a user