etcdctlv3: consolidate dial code; use clientv3

This commit is contained in:
Anthony Romano
2016-01-27 10:25:04 -08:00
parent 5ccf7f5151
commit 9a5a3ebc79
9 changed files with 36 additions and 163 deletions

View File

@ -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))