2016-06-13 19:56:23 -07:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/client"
|
|
|
|
"github.com/docker/docker/cli"
|
|
|
|
"github.com/docker/engine-api/types/swarm"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newAcceptCommand(dockerCli *client.DockerCli) *cobra.Command {
|
2016-06-17 11:26:53 -04:00
|
|
|
return &cobra.Command{
|
2016-06-13 19:56:23 -07:00
|
|
|
Use: "accept NODE [NODE...]",
|
|
|
|
Short: "Accept a node in the swarm",
|
|
|
|
Args: cli.RequiresMinArgs(1),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2016-06-17 11:26:53 -04:00
|
|
|
return runAccept(dockerCli, args)
|
2016-06-13 19:56:23 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-17 11:26:53 -04:00
|
|
|
func runAccept(dockerCli *client.DockerCli, nodes []string) error {
|
|
|
|
accept := func(node *swarm.Node) {
|
|
|
|
node.Spec.Membership = swarm.NodeMembershipAccepted
|
2016-06-13 19:56:23 -07:00
|
|
|
}
|
2016-06-17 11:26:53 -04:00
|
|
|
success := func(nodeID string) {
|
|
|
|
fmt.Fprintf(dockerCli.Out(), "Node %s accepted in the swarm.\n", nodeID)
|
|
|
|
}
|
|
|
|
return updateNodes(dockerCli, nodes, accept, success)
|
2016-06-13 19:56:23 -07:00
|
|
|
}
|