From 167c7114677c3f1d72cd80bc2fde2ce70ee66396 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 9 May 2018 13:17:55 -0700 Subject: [PATCH] etcdctl/ctlv3: fix fmt test warnings Signed-off-by: Gyuho Lee --- etcdctl/ctlv3/command/del_command.go | 4 ++-- etcdctl/ctlv3/command/get_command.go | 4 ++-- etcdctl/ctlv3/command/put_command.go | 4 ++-- etcdctl/ctlv3/command/txn_command.go | 10 ++++------ etcdctl/ctlv3/command/watch_command.go | 8 ++++---- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/etcdctl/ctlv3/command/del_command.go b/etcdctl/ctlv3/command/del_command.go index bb0663024..00c93bf5b 100644 --- a/etcdctl/ctlv3/command/del_command.go +++ b/etcdctl/ctlv3/command/del_command.go @@ -43,7 +43,7 @@ func NewDelCommand() *cobra.Command { // delCommandFunc executes the "del" command. func delCommandFunc(cmd *cobra.Command, args []string) { - key, opts := getDelOp(cmd, args) + key, opts := getDelOp(args) ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...) cancel() @@ -53,7 +53,7 @@ func delCommandFunc(cmd *cobra.Command, args []string) { display.Del(*resp) } -func getDelOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) { +func getDelOp(args []string) (string, []clientv3.OpOption) { if len(args) == 0 || len(args) > 2 { ExitWithError(ExitBadArgs, fmt.Errorf("del command needs one argument as key and an optional argument as range_end.")) } diff --git a/etcdctl/ctlv3/command/get_command.go b/etcdctl/ctlv3/command/get_command.go index 5f9c74f3c..85848b579 100644 --- a/etcdctl/ctlv3/command/get_command.go +++ b/etcdctl/ctlv3/command/get_command.go @@ -56,7 +56,7 @@ func NewGetCommand() *cobra.Command { // getCommandFunc executes the "get" command. func getCommandFunc(cmd *cobra.Command, args []string) { - key, opts := getGetOp(cmd, args) + key, opts := getGetOp(args) ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...) cancel() @@ -74,7 +74,7 @@ func getCommandFunc(cmd *cobra.Command, args []string) { display.Get(*resp) } -func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) { +func getGetOp(args []string) (string, []clientv3.OpOption) { if len(args) == 0 { ExitWithError(ExitBadArgs, fmt.Errorf("range command needs arguments.")) } diff --git a/etcdctl/ctlv3/command/put_command.go b/etcdctl/ctlv3/command/put_command.go index a72f0c4dc..21db69bda 100644 --- a/etcdctl/ctlv3/command/put_command.go +++ b/etcdctl/ctlv3/command/put_command.go @@ -65,7 +65,7 @@ will store the content of the file to . // putCommandFunc executes the "put" command. func putCommandFunc(cmd *cobra.Command, args []string) { - key, value, opts := getPutOp(cmd, args) + key, value, opts := getPutOp(args) ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...) @@ -76,7 +76,7 @@ func putCommandFunc(cmd *cobra.Command, args []string) { display.Put(*resp) } -func getPutOp(cmd *cobra.Command, args []string) (string, string, []clientv3.OpOption) { +func getPutOp(args []string) (string, string, []clientv3.OpOption) { if len(args) == 0 { ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments.")) } diff --git a/etcdctl/ctlv3/command/txn_command.go b/etcdctl/ctlv3/command/txn_command.go index eec1e0916..e18a7e9bd 100644 --- a/etcdctl/ctlv3/command/txn_command.go +++ b/etcdctl/ctlv3/command/txn_command.go @@ -28,9 +28,7 @@ import ( "github.com/spf13/cobra" ) -var ( - txnInteractive bool -) +var txnInteractive bool // NewTxnCommand returns the cobra command for "txn". func NewTxnCommand() *cobra.Command { @@ -129,17 +127,17 @@ func parseRequestUnion(line string) (*clientv3.Op, error) { put := NewPutCommand() put.Run = func(cmd *cobra.Command, args []string) { - key, value, opts := getPutOp(cmd, args) + key, value, opts := getPutOp(args) opc <- clientv3.OpPut(key, value, opts...) } get := NewGetCommand() get.Run = func(cmd *cobra.Command, args []string) { - key, opts := getGetOp(cmd, args) + key, opts := getGetOp(args) opc <- clientv3.OpGet(key, opts...) } del := NewDelCommand() del.Run = func(cmd *cobra.Command, args []string) { - key, opts := getDelOp(cmd, args) + key, opts := getDelOp(args) opc <- clientv3.OpDelete(key, opts...) } cmds := &cobra.Command{SilenceErrors: true} diff --git a/etcdctl/ctlv3/command/watch_command.go b/etcdctl/ctlv3/command/watch_command.go index 1a2cc4213..15cc835be 100644 --- a/etcdctl/ctlv3/command/watch_command.go +++ b/etcdctl/ctlv3/command/watch_command.go @@ -258,9 +258,9 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter } flagset := NewWatchCommand().Flags() - if err := flagset.Parse(watchArgs); err != nil { + if perr := flagset.Parse(watchArgs); perr != nil { watchPrefix, watchRev, watchPrevKey = false, 0, false - return nil, nil, err + return nil, nil, perr } pArgs := flagset.Args() @@ -298,8 +298,8 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter if interactive { flagset := NewWatchCommand().Flags() - if err := flagset.Parse(argsWithSep); err != nil { - return nil, nil, err + if perr := flagset.Parse(argsWithSep); perr != nil { + return nil, nil, perr } watchArgs = flagset.Args()