Преглед изворни кода

etcdctl: a new option for quorum get

Current etcdctl seems to lack an option for specifying quorum flag for
GET. This commit adds the option.
Hitoshi Mitake пре 10 година
родитељ
комит
11f49a0960
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      etcdctl/command/get_command.go

+ 3 - 1
etcdctl/command/get_command.go

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