mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: support member update command
This commit is contained in:
parent
6e3769d39e
commit
ee82ee05b4
@ -44,6 +44,11 @@ func NewMemberCommand() cli.Command {
|
||||
Usage: "remove an existing member from the etcd cluster",
|
||||
Action: actionMemberRemove,
|
||||
},
|
||||
cli.Command{
|
||||
Name: "update",
|
||||
Usage: "update an existing member in the etcd cluster",
|
||||
Action: actionMemberUpdate,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -163,3 +168,25 @@ func actionMemberRemove(c *cli.Context) {
|
||||
|
||||
fmt.Printf("Removed member %s from cluster\n", removalID)
|
||||
}
|
||||
|
||||
func actionMemberUpdate(c *cli.Context) {
|
||||
args := c.Args()
|
||||
if len(args) != 2 {
|
||||
fmt.Fprintln(os.Stderr, "Provide an ID and a list of comma separated peerURL (0xabcd http://example.com,http://example1.com)")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
mAPI := mustNewMembersAPI(c)
|
||||
|
||||
mid := args[0]
|
||||
urls := args[1]
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
|
||||
err := mAPI.Update(ctx, mid, strings.Split(urls, ","))
|
||||
cancel()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Updated member with ID %s in cluster\n", mid)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user