Browse Source

etcdctl/ctlv3: fix fmt test warnings

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
167c711467

+ 2 - 2
etcdctl/ctlv3/command/del_command.go

@@ -43,7 +43,7 @@ func NewDelCommand() *cobra.Command {
 
 
 // delCommandFunc executes the "del" command.
 // delCommandFunc executes the "del" command.
 func delCommandFunc(cmd *cobra.Command, args []string) {
 func delCommandFunc(cmd *cobra.Command, args []string) {
-	key, opts := getDelOp(cmd, args)
+	key, opts := getDelOp(args)
 	ctx, cancel := commandCtx(cmd)
 	ctx, cancel := commandCtx(cmd)
 	resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
 	resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
 	cancel()
 	cancel()
@@ -53,7 +53,7 @@ func delCommandFunc(cmd *cobra.Command, args []string) {
 	display.Del(*resp)
 	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 {
 	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."))
 		ExitWithError(ExitBadArgs, fmt.Errorf("del command needs one argument as key and an optional argument as range_end."))
 	}
 	}

+ 2 - 2
etcdctl/ctlv3/command/get_command.go

@@ -56,7 +56,7 @@ func NewGetCommand() *cobra.Command {
 
 
 // getCommandFunc executes the "get" command.
 // getCommandFunc executes the "get" command.
 func getCommandFunc(cmd *cobra.Command, args []string) {
 func getCommandFunc(cmd *cobra.Command, args []string) {
-	key, opts := getGetOp(cmd, args)
+	key, opts := getGetOp(args)
 	ctx, cancel := commandCtx(cmd)
 	ctx, cancel := commandCtx(cmd)
 	resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...)
 	resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...)
 	cancel()
 	cancel()
@@ -74,7 +74,7 @@ func getCommandFunc(cmd *cobra.Command, args []string) {
 	display.Get(*resp)
 	display.Get(*resp)
 }
 }
 
 
-func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
+func getGetOp(args []string) (string, []clientv3.OpOption) {
 	if len(args) == 0 {
 	if len(args) == 0 {
 		ExitWithError(ExitBadArgs, fmt.Errorf("range command needs arguments."))
 		ExitWithError(ExitBadArgs, fmt.Errorf("range command needs arguments."))
 	}
 	}

+ 2 - 2
etcdctl/ctlv3/command/put_command.go

@@ -65,7 +65,7 @@ will store the content of the file to <key>.
 
 
 // putCommandFunc executes the "put" command.
 // putCommandFunc executes the "put" command.
 func putCommandFunc(cmd *cobra.Command, args []string) {
 func putCommandFunc(cmd *cobra.Command, args []string) {
-	key, value, opts := getPutOp(cmd, args)
+	key, value, opts := getPutOp(args)
 
 
 	ctx, cancel := commandCtx(cmd)
 	ctx, cancel := commandCtx(cmd)
 	resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
 	resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
@@ -76,7 +76,7 @@ func putCommandFunc(cmd *cobra.Command, args []string) {
 	display.Put(*resp)
 	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 {
 	if len(args) == 0 {
 		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
 		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
 	}
 	}

+ 4 - 6
etcdctl/ctlv3/command/txn_command.go

@@ -28,9 +28,7 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra"
 )
 )
 
 
-var (
-	txnInteractive bool
-)
+var txnInteractive bool
 
 
 // NewTxnCommand returns the cobra command for "txn".
 // NewTxnCommand returns the cobra command for "txn".
 func NewTxnCommand() *cobra.Command {
 func NewTxnCommand() *cobra.Command {
@@ -129,17 +127,17 @@ func parseRequestUnion(line string) (*clientv3.Op, error) {
 
 
 	put := NewPutCommand()
 	put := NewPutCommand()
 	put.Run = func(cmd *cobra.Command, args []string) {
 	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...)
 		opc <- clientv3.OpPut(key, value, opts...)
 	}
 	}
 	get := NewGetCommand()
 	get := NewGetCommand()
 	get.Run = func(cmd *cobra.Command, args []string) {
 	get.Run = func(cmd *cobra.Command, args []string) {
-		key, opts := getGetOp(cmd, args)
+		key, opts := getGetOp(args)
 		opc <- clientv3.OpGet(key, opts...)
 		opc <- clientv3.OpGet(key, opts...)
 	}
 	}
 	del := NewDelCommand()
 	del := NewDelCommand()
 	del.Run = func(cmd *cobra.Command, args []string) {
 	del.Run = func(cmd *cobra.Command, args []string) {
-		key, opts := getDelOp(cmd, args)
+		key, opts := getDelOp(args)
 		opc <- clientv3.OpDelete(key, opts...)
 		opc <- clientv3.OpDelete(key, opts...)
 	}
 	}
 	cmds := &cobra.Command{SilenceErrors: true}
 	cmds := &cobra.Command{SilenceErrors: true}

+ 4 - 4
etcdctl/ctlv3/command/watch_command.go

@@ -258,9 +258,9 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter
 		}
 		}
 
 
 		flagset := NewWatchCommand().Flags()
 		flagset := NewWatchCommand().Flags()
-		if err := flagset.Parse(watchArgs); err != nil {
+		if perr := flagset.Parse(watchArgs); perr != nil {
 			watchPrefix, watchRev, watchPrevKey = false, 0, false
 			watchPrefix, watchRev, watchPrevKey = false, 0, false
-			return nil, nil, err
+			return nil, nil, perr
 		}
 		}
 		pArgs := flagset.Args()
 		pArgs := flagset.Args()
 
 
@@ -298,8 +298,8 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter
 
 
 	if interactive {
 	if interactive {
 		flagset := NewWatchCommand().Flags()
 		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()
 		watchArgs = flagset.Args()