Skip to content

Commit

Permalink
etcdctl/command: mk command with Create
Browse files Browse the repository at this point in the history
- This attempts to fix #3676.
- The previous pull request (#3679) was
  trying to change the interface so that it can be executed with TTL flags.
- Since `Create` is just a simple wrapper of `Set`, there is no need changing
  the interface, which means we need to remove the TTL flags from `mk` command.

/cc @yichengq
  • Loading branch information
gyuho committed Oct 15, 2015
1 parent afd74df commit 938abeb
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions etcdctl/command/mk_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package command
import (
"errors"
"os"
"time"

"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
"github.com/coreos/etcd/client"
Expand All @@ -28,9 +27,6 @@ func NewMakeCommand() cli.Command {
return cli.Command{
Name: "mk",
Usage: "make a new key with a given value",
Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
},
Action: func(c *cli.Context) {
mkCommandFunc(c, mustNewKeyAPI(c))
},
Expand All @@ -48,10 +44,8 @@ func mkCommandFunc(c *cli.Context, ki client.KeysAPI) {
handleError(ExitBadArgs, errors.New("value required"))
}

ttl := c.Int("ttl")

ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Set(ctx, key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevIgnore})
resp, err := ki.Create(ctx, key, value)
cancel()
if err != nil {
handleError(ExitServerError, err)
Expand Down

0 comments on commit 938abeb

Please sign in to comment.