Browse Source

*: error strings should not end with punctuation or a newline (ST1005)

Signed-off-by: Sam Batschelet <sbatsche@redhat.com>
Sam Batschelet 7 years ago
parent
commit
a82703b69e

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

@@ -45,7 +45,7 @@ func newAuthEnableCommand() *cobra.Command {
 // authEnableCommandFunc executes the "auth enable" command.
 func authEnableCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("auth enable command does not accept any arguments."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("auth enable command does not accept any arguments"))
 	}
 
 	ctx, cancel := commandCtx(cmd)
@@ -83,7 +83,7 @@ func newAuthDisableCommand() *cobra.Command {
 // authDisableCommandFunc executes the "auth disable" command.
 func authDisableCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments"))
 	}
 
 	ctx, cancel := commandCtx(cmd)

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

@@ -163,7 +163,7 @@ func newCheckPerfCommand(cmd *cobra.Command, args []string) {
 		ExitWithError(ExitError, err)
 	}
 	if len(resp.Kvs) > 0 {
-		ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s first.", checkPerfPrefix, checkPerfPrefix))
+		ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s first", checkPerfPrefix, checkPerfPrefix))
 	}
 
 	ksize, vsize := 256, 1024
@@ -318,7 +318,7 @@ func newCheckDatascaleCommand(cmd *cobra.Command, args []string) {
 		ExitWithError(ExitError, err)
 	}
 	if len(resp.Kvs) > 0 {
-		ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s first.", checkDatascalePrefix, checkDatascalePrefix))
+		ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s first", checkDatascalePrefix, checkDatascalePrefix))
 	}
 
 	ksize, vsize := 512, 512

+ 1 - 1
etcdctl/ctlv3/command/compaction_command.go

@@ -38,7 +38,7 @@ func NewCompactionCommand() *cobra.Command {
 // compactionCommandFunc executes the "compaction" command.
 func compactionCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("compaction command needs 1 argument"))
 	}
 
 	rev, err := strconv.ParseInt(args[0], 10, 64)

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

@@ -55,18 +55,18 @@ func delCommandFunc(cmd *cobra.Command, args []string) {
 
 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."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("del command needs one argument as key and an optional argument as range_end"))
 	}
 
 	if delPrefix && delFromKey {
-		ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one"))
 	}
 
 	opts := []clientv3.OpOption{}
 	key := args[0]
 	if len(args) > 1 {
 		if delPrefix || delFromKey {
-			ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set."))
+			ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set"))
 		}
 		opts = append(opts, clientv3.WithRange(args[1]))
 	}

+ 1 - 1
etcdctl/ctlv3/command/elect_command.go

@@ -44,7 +44,7 @@ func NewElectCommand() *cobra.Command {
 
 func electCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 && len(args) != 2 {
-		ExitWithError(ExitBadArgs, errors.New("elect takes one election name argument and an optional proposal argument."))
+		ExitWithError(ExitBadArgs, errors.New("elect takes one election name argument and an optional proposal argument"))
 	}
 	c := mustClientFromCmd(cmd)
 

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

@@ -67,7 +67,7 @@ func getCommandFunc(cmd *cobra.Command, args []string) {
 	if printValueOnly {
 		dp, simple := (display).(*simplePrinter)
 		if !simple {
-			ExitWithError(ExitBadArgs, fmt.Errorf("print-value-only is only for `--write-out=simple`."))
+			ExitWithError(ExitBadArgs, fmt.Errorf("print-value-only is only for `--write-out=simple`"))
 		}
 		dp.valueOnly = true
 	}
@@ -76,11 +76,11 @@ func getCommandFunc(cmd *cobra.Command, args []string) {
 
 func getGetOp(args []string) (string, []clientv3.OpOption) {
 	if len(args) == 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("get command needs one argument as key and an optional argument as range_end."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("get command needs one argument as key and an optional argument as range_end"))
 	}
 
 	if getPrefix && getFromKey {
-		ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("`--prefix` and `--from-key` cannot be set at the same time, choose one"))
 	}
 
 	opts := []clientv3.OpOption{}
@@ -95,7 +95,7 @@ func getGetOp(args []string) (string, []clientv3.OpOption) {
 	key := args[0]
 	if len(args) > 1 {
 		if getPrefix || getFromKey {
-			ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set."))
+			ExitWithError(ExitBadArgs, fmt.Errorf("too many arguments, only accept one argument when `--prefix` or `--from-key` is set"))
 		}
 		opts = append(opts, clientv3.WithRange(args[1]))
 	}

+ 3 - 3
etcdctl/ctlv3/command/lease_command.go

@@ -55,7 +55,7 @@ func NewLeaseGrantCommand() *cobra.Command {
 // leaseGrantCommandFunc executes the "lease grant" command.
 func leaseGrantCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument"))
 	}
 
 	ttl, err := strconv.ParseInt(args[0], 10, 64)
@@ -67,7 +67,7 @@ func leaseGrantCommandFunc(cmd *cobra.Command, args []string) {
 	resp, err := mustClientFromCmd(cmd).Grant(ctx, ttl)
 	cancel()
 	if err != nil {
-		ExitWithError(ExitError, fmt.Errorf("failed to grant lease (%v)\n", err))
+		ExitWithError(ExitError, fmt.Errorf("failed to grant lease (%v)", err))
 	}
 	display.Grant(*resp)
 }
@@ -95,7 +95,7 @@ func leaseRevokeCommandFunc(cmd *cobra.Command, args []string) {
 	resp, err := mustClientFromCmd(cmd).Revoke(ctx, id)
 	cancel()
 	if err != nil {
-		ExitWithError(ExitError, fmt.Errorf("failed to revoke lease (%v)\n", err))
+		ExitWithError(ExitError, fmt.Errorf("failed to revoke lease (%v)", err))
 	}
 	display.Revoke(id, *resp)
 }

+ 1 - 1
etcdctl/ctlv3/command/lock_command.go

@@ -44,7 +44,7 @@ func NewLockCommand() *cobra.Command {
 
 func lockCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) == 0 {
-		ExitWithError(ExitBadArgs, errors.New("lock takes a lock name argument and an optional command to execute."))
+		ExitWithError(ExitBadArgs, errors.New("lock takes a lock name argument and an optional command to execute"))
 	}
 	c := mustClientFromCmd(cmd)
 	if err := lockUntilSignal(c, args[0], args[1:]); err != nil {

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

@@ -62,7 +62,7 @@ func NewMakeMirrorCommand() *cobra.Command {
 
 func makeMirrorCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination argument."))
+		ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination argument"))
 	}
 
 	dialTimeout := dialTimeoutFromCmd(cmd)
@@ -106,7 +106,7 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er
 
 	// if destination prefix is specified and remove destination prefix is true return error
 	if mmnodestprefix && len(mmdestprefix) > 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("`--dest-prefix` and `--no-dest-prefix` cannot be set at the same time, choose one."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("`--dest-prefix` and `--no-dest-prefix` cannot be set at the same time, choose one"))
 	}
 
 	// if remove destination prefix is false and destination prefix is empty set the value of destination prefix same as prefix

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

@@ -78,12 +78,12 @@ func putCommandFunc(cmd *cobra.Command, args []string) {
 
 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."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments"))
 	}
 
 	key := args[0]
 	if putIgnoreVal && len(args) > 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs only 1 argument when 'ignore-value' is set."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("put command needs only 1 argument when 'ignore-value' is set"))
 	}
 
 	var value string
@@ -91,7 +91,7 @@ func getPutOp(args []string) (string, string, []clientv3.OpOption) {
 	if !putIgnoreVal {
 		value, err = argOrStdin(args, os.Stdin, 1)
 		if err != nil {
-			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"))
 		}
 	}
 

+ 6 - 6
etcdctl/ctlv3/command/role_command.go

@@ -105,7 +105,7 @@ func newRoleRevokePermissionCommand() *cobra.Command {
 // roleAddCommandFunc executes the "role add" command.
 func roleAddCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role add command requires role name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role add command requires role name as its argument"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.RoleAdd(context.TODO(), args[0])
@@ -119,7 +119,7 @@ func roleAddCommandFunc(cmd *cobra.Command, args []string) {
 // roleDeleteCommandFunc executes the "role delete" command.
 func roleDeleteCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role delete command requires role name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role delete command requires role name as its argument"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.RoleDelete(context.TODO(), args[0])
@@ -133,7 +133,7 @@ func roleDeleteCommandFunc(cmd *cobra.Command, args []string) {
 // roleGetCommandFunc executes the "role get" command.
 func roleGetCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role get command requires role name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role get command requires role name as its argument"))
 	}
 
 	name := args[0]
@@ -148,7 +148,7 @@ func roleGetCommandFunc(cmd *cobra.Command, args []string) {
 // roleListCommandFunc executes the "role list" command.
 func roleListCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role list command requires no arguments."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role list command requires no arguments"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.RoleList(context.TODO())
@@ -162,7 +162,7 @@ func roleListCommandFunc(cmd *cobra.Command, args []string) {
 // roleGrantPermissionCommandFunc executes the "role grant-permission" command.
 func roleGrantPermissionCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) < 3 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role grant command requires role name, permission type, and key [endkey] as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role grant command requires role name, permission type, and key [endkey] as its argument"))
 	}
 
 	perm, err := clientv3.StrToPermissionType(args[1])
@@ -182,7 +182,7 @@ func roleGrantPermissionCommandFunc(cmd *cobra.Command, args []string) {
 // roleRevokePermissionCommandFunc executes the "role revoke-permission" command.
 func roleRevokePermissionCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) < 2 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("role revoke-permission command requires role name and key [endkey] as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("role revoke-permission command requires role name and key [endkey] as its argument"))
 	}
 
 	key, rangeEnd := permRange(args[1:])

+ 1 - 1
etcdctl/ctlv3/command/txn_command.go

@@ -44,7 +44,7 @@ func NewTxnCommand() *cobra.Command {
 // txnCommandFunc executes the "txn" command.
 func txnCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("txn command does not accept argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("txn command does not accept argument"))
 	}
 
 	reader := bufio.NewReader(os.Stdin)

+ 11 - 11
etcdctl/ctlv3/command/user_command.go

@@ -122,7 +122,7 @@ func newUserRevokeRoleCommand() *cobra.Command {
 // userAddCommandFunc executes the "user add" command.
 func userAddCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user add command requires user name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user add command requires user name as its argument"))
 	}
 
 	var password string
@@ -144,7 +144,7 @@ func userAddCommandFunc(cmd *cobra.Command, args []string) {
 			user = splitted[0]
 			password = splitted[1]
 			if len(user) == 0 {
-				ExitWithError(ExitBadArgs, fmt.Errorf("empty user name is not allowed."))
+				ExitWithError(ExitBadArgs, fmt.Errorf("empty user name is not allowed"))
 			}
 		}
 	}
@@ -160,7 +160,7 @@ func userAddCommandFunc(cmd *cobra.Command, args []string) {
 // userDeleteCommandFunc executes the "user delete" command.
 func userDeleteCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user delete command requires user name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user delete command requires user name as its argument"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.UserDelete(context.TODO(), args[0])
@@ -173,7 +173,7 @@ func userDeleteCommandFunc(cmd *cobra.Command, args []string) {
 // userGetCommandFunc executes the "user get" command.
 func userGetCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user get command requires user name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user get command requires user name as its argument"))
 	}
 
 	name := args[0]
@@ -201,7 +201,7 @@ func userGetCommandFunc(cmd *cobra.Command, args []string) {
 // userListCommandFunc executes the "user list" command.
 func userListCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 0 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user list command requires no arguments."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user list command requires no arguments"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.UserList(context.TODO())
@@ -215,7 +215,7 @@ func userListCommandFunc(cmd *cobra.Command, args []string) {
 // userChangePasswordCommandFunc executes the "user passwd" command.
 func userChangePasswordCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 1 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user passwd command requires user name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user passwd command requires user name as its argument"))
 	}
 
 	var password string
@@ -237,7 +237,7 @@ func userChangePasswordCommandFunc(cmd *cobra.Command, args []string) {
 // userGrantRoleCommandFunc executes the "user grant-role" command.
 func userGrantRoleCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 2 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user grant command requires user name and role name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user grant command requires user name and role name as its argument"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.UserGrantRole(context.TODO(), args[0], args[1])
@@ -251,7 +251,7 @@ func userGrantRoleCommandFunc(cmd *cobra.Command, args []string) {
 // userRevokeRoleCommandFunc executes the "user revoke-role" command.
 func userRevokeRoleCommandFunc(cmd *cobra.Command, args []string) {
 	if len(args) != 2 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("user revoke-role requires user name and role name as its argument."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("user revoke-role requires user name and role name as its argument"))
 	}
 
 	resp, err := mustClientFromCmd(cmd).Auth.UserRevokeRole(context.TODO(), args[0], args[1])
@@ -266,7 +266,7 @@ func readPasswordInteractive(name string) string {
 	prompt1 := fmt.Sprintf("Password of %s: ", name)
 	password1, err1 := speakeasy.Ask(prompt1)
 	if err1 != nil {
-		ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s.", err1))
+		ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s", err1))
 	}
 
 	if len(password1) == 0 {
@@ -276,11 +276,11 @@ func readPasswordInteractive(name string) string {
 	prompt2 := fmt.Sprintf("Type password of %s again for confirmation: ", name)
 	password2, err2 := speakeasy.Ask(prompt2)
 	if err2 != nil {
-		ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s.", err2))
+		ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s", err2))
 	}
 
 	if password1 != password2 {
-		ExitWithError(ExitBadArgs, fmt.Errorf("given passwords are different."))
+		ExitWithError(ExitBadArgs, fmt.Errorf("given passwords are different"))
 	}
 
 	return password1

+ 2 - 2
etcdserver/api/v2http/client.go

@@ -161,7 +161,7 @@ func (h *keysHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		defer cancel()
 		handleKeyWatch(ctx, h.lg, w, resp, rr.Stream)
 	default:
-		writeKeyError(h.lg, w, errors.New("received response with no Event/Watcher!"))
+		writeKeyError(h.lg, w, errors.New("received response with no Event/Watcher"))
 	}
 }
 
@@ -556,7 +556,7 @@ func parseKeyRequest(r *http.Request, clock clockwork.Clock) (etcdserverpb.Reque
 func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error {
 	ev := resp.Event
 	if ev == nil {
-		return errors.New("cannot write empty Event!")
+		return errors.New("cannot write empty Event")
 	}
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex))