mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: minor cleanup
This commit is contained in:
parent
079e7c10a0
commit
f0edf06b6d
@ -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.
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -111,5 +111,4 @@ func getTransport(c *cli.Context) (*http.Transport, error) {
|
||||
KeyFile: keyfile,
|
||||
}
|
||||
return transport.NewTransport(tls)
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user