浏览代码

etcdctl: minor cleanup

Xiang Li 10 年之前
父节点
当前提交
f0edf06b6d

+ 1 - 1
etcdctl/command/format.go

@@ -19,7 +19,7 @@ import (
 	"fmt"
 	"os"
 
-	"github.com/coreos/go-etcd/etcd"
+	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd"
 )
 
 // printKey writes the etcd response to STDOUT in the given format.

+ 1 - 1
etcdctl/command/get_command.go

@@ -55,7 +55,7 @@ func printGet(resp *etcd.Response, format string) {
 // getCommandFunc executes the "get" command.
 func getCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 	sorted := c.Bool("sort")

+ 2 - 2
etcdctl/command/mk_command.go

@@ -39,12 +39,12 @@ func NewMakeCommand() cli.Command {
 // makeCommandFunc executes the "make" command.
 func makeCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 	value, err := argOrStdin(c.Args(), os.Stdin, 1)
 	if err != nil {
-		return nil, errors.New("Value required")
+		return nil, errors.New("value required")
 	}
 
 	ttl := c.Int("ttl")

+ 1 - 1
etcdctl/command/mkdir_command.go

@@ -38,7 +38,7 @@ func NewMakeDirCommand() cli.Command {
 // makeDirCommandFunc executes the "mkdir" command.
 func makeDirCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 	ttl := c.Int("ttl")

+ 1 - 1
etcdctl/command/rm_command.go

@@ -41,7 +41,7 @@ func NewRemoveCommand() cli.Command {
 // removeCommandFunc executes the "rm" command.
 func removeCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 	recursive := c.Bool("recursive")

+ 1 - 1
etcdctl/command/rmdir_command.go

@@ -35,7 +35,7 @@ func NewRemoveDirCommand() cli.Command {
 // removeDirCommandFunc executes the "rmdir" command.
 func removeDirCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 

+ 3 - 4
etcdctl/command/set_command.go

@@ -41,12 +41,12 @@ func NewSetCommand() cli.Command {
 // setCommandFunc executes the "set" command.
 func setCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
 	if len(c.Args()) == 0 {
-		return nil, errors.New("Key required")
+		return nil, errors.New("key required")
 	}
 	key := c.Args()[0]
 	value, err := argOrStdin(c.Args(), os.Stdin, 1)
 	if err != nil {
-		return nil, errors.New("Value required")
+		return nil, errors.New("value required")
 	}
 
 	ttl := c.Int("ttl")
@@ -55,7 +55,6 @@ func setCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error)
 
 	if prevValue == "" && prevIndex == 0 {
 		return client.Set(key, value, uint64(ttl))
-	} else {
-		return client.CompareAndSwap(key, value, uint64(ttl), prevValue, uint64(prevIndex))
 	}
+	return client.CompareAndSwap(key, value, uint64(ttl), prevValue, uint64(prevIndex))
 }

+ 0 - 1
etcdctl/command/util.go

@@ -111,5 +111,4 @@ func getTransport(c *cli.Context) (*http.Transport, error) {
 		KeyFile:  keyfile,
 	}
 	return transport.NewTransport(tls)
-
 }