From 8b3405bdb8862bdee56e3e710e425b6d64aaa019 Mon Sep 17 00:00:00 2001 From: ahrtr Date: Tue, 30 Nov 2021 06:14:52 +0800 Subject: [PATCH] etcdctl: enhance the make-mirror command to return error asap with wrong command line parameters --- etcdctl/ctlv3/command/make_mirror_command.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/etcdctl/ctlv3/command/make_mirror_command.go b/etcdctl/ctlv3/command/make_mirror_command.go index aaa51eae9..777c1dd0c 100644 --- a/etcdctl/ctlv3/command/make_mirror_command.go +++ b/etcdctl/ctlv3/command/make_mirror_command.go @@ -130,6 +130,11 @@ func makeMirrorCommandFunc(cmd *cobra.Command, args []string) { func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) error { total := int64(0) + // if destination prefix is specified and remove destination prefix is true return error + if mmnodestprefix && len(mmdestprefix) > 0 { + cobrautl.ExitWithError(cobrautl.ExitBadArgs, errors.New("`--dest-prefix` and `--no-dest-prefix` cannot be set at the same time, choose one")) + } + go func() { for { time.Sleep(30 * time.Second) @@ -141,11 +146,6 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er rc, errc := s.SyncBase(ctx) - // if destination prefix is specified and remove destination prefix is true return error - if mmnodestprefix && len(mmdestprefix) > 0 { - cobrautl.ExitWithError(cobrautl.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 if !mmnodestprefix && len(mmdestprefix) == 0 { mmdestprefix = mmprefix