Merge pull request #3898 from mitake/get-quorum

etcdctl: a new option for quorum get
This commit is contained in:
Xiang Li 2015-11-20 08:08:49 -08:00
commit b104df4b17

View File

@ -30,6 +30,7 @@ func NewGetCommand() cli.Command {
Usage: "retrieve the value of a key",
Flags: []cli.Flag{
cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
cli.BoolFlag{Name: "quorum", Usage: "require quorum for get request"},
},
Action: func(c *cli.Context) {
getCommandFunc(c, mustNewKeyAPI(c))
@ -45,9 +46,10 @@ func getCommandFunc(c *cli.Context, ki client.KeysAPI) {
key := c.Args()[0]
sorted := c.Bool("sort")
quorum := c.Bool("quorum")
ctx, cancel := contextWithTotalTimeout(c)
resp, err := ki.Get(ctx, key, &client.GetOptions{Sort: sorted})
resp, err := ki.Get(ctx, key, &client.GetOptions{Sort: sorted, Quorum: quorum})
cancel()
if err != nil {
handleError(ExitServerError, err)