github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/api/client/node/demote.go (about) 1 package node 2 3 import ( 4 "fmt" 5 6 "github.com/docker/docker/api/client" 7 "github.com/docker/docker/cli" 8 "github.com/docker/engine-api/types/swarm" 9 "github.com/spf13/cobra" 10 ) 11 12 func newDemoteCommand(dockerCli *client.DockerCli) *cobra.Command { 13 return &cobra.Command{ 14 Use: "demote NODE [NODE...]", 15 Short: "Demote a node from manager in the swarm", 16 Args: cli.RequiresMinArgs(1), 17 RunE: func(cmd *cobra.Command, args []string) error { 18 return runDemote(dockerCli, args) 19 }, 20 } 21 } 22 23 func runDemote(dockerCli *client.DockerCli, nodes []string) error { 24 demote := func(node *swarm.Node) { 25 node.Spec.Role = swarm.NodeRoleWorker 26 } 27 success := func(nodeID string) { 28 fmt.Fprintf(dockerCli.Out(), "Manager %s demoted in the swarm.\n", nodeID) 29 } 30 return updateNodes(dockerCli, nodes, demote, success) 31 }