etcdctl: support MemberAdd for learner

Added support for "etcdctl member add --learner".
release-3.4
Jingyi Hu 2019-03-19 18:55:48 -07:00
parent fc14608cb7
commit a67d934410
1 changed files with 6 additions and 2 deletions

View File

@ -23,7 +23,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var memberPeerURLs string var (
memberPeerURLs string
isLearner bool
)
// NewMemberCommand returns the cobra command for "member". // NewMemberCommand returns the cobra command for "member".
func NewMemberCommand() *cobra.Command { func NewMemberCommand() *cobra.Command {
@ -50,6 +53,7 @@ func NewMemberAddCommand() *cobra.Command {
} }
cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the new member.") cc.Flags().StringVar(&memberPeerURLs, "peer-urls", "", "comma separated peer URLs for the new member.")
cc.Flags().BoolVar(&isLearner, "learner", false, "indicates if the new member is raft learner")
return cc return cc
} }
@ -118,7 +122,7 @@ func memberAddCommandFunc(cmd *cobra.Command, args []string) {
urls := strings.Split(memberPeerURLs, ",") urls := strings.Split(memberPeerURLs, ",")
ctx, cancel := commandCtx(cmd) ctx, cancel := commandCtx(cmd)
cli := mustClientFromCmd(cmd) cli := mustClientFromCmd(cmd)
resp, err := cli.MemberAdd(ctx, urls, false) resp, err := cli.MemberAdd(ctx, urls, isLearner)
cancel() cancel()
if err != nil { if err != nil {
ExitWithError(ExitError, err) ExitWithError(ExitError, err)