Refactor common code from etcdctl (v2,v3) to pkg/corbautl.

Preparation for etcdutl split.
This commit is contained in:
Piotr Tabor
2021-05-14 14:16:53 +02:00
parent eae7a845a7
commit 00c6090110
52 changed files with 553 additions and 276 deletions

View File

@@ -20,6 +20,7 @@ import (
"github.com/urfave/cli"
"go.etcd.io/etcd/client/v2"
"go.etcd.io/etcd/pkg/v3/cobrautl"
)
// NewUpdateDirCommand returns the CLI command for "updatedir".
@@ -41,7 +42,7 @@ func NewUpdateDirCommand() cli.Command {
// updatedirCommandFunc executes the "updatedir" command.
func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(c, ExitBadArgs, errors.New("key required"))
handleError(c, cobrautl.ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ttl := c.Int("ttl")
@@ -49,7 +50,7 @@ func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: client.PrevExist})
cancel()
if err != nil {
handleError(c, ExitServerError, err)
handleError(c, cobrautl.ExitServerError, err)
}
if c.GlobalString("output") != "simple" {
printResponseKey(resp, c.GlobalString("output"))