2016-06-13 22:56:23 -04: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"
|
|
|
|
"github.com/spf13/pflag"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newAcceptCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
|
|
var flags *pflag.FlagSet
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "accept NODE [NODE...]",
|
|
|
|
Short: "Accept a node in the swarm",
|
|
|
|
Args: cli.RequiresMinArgs(1),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return runAccept(dockerCli, flags, args)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = cmd.Flags()
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func runAccept(dockerCli *client.DockerCli, flags *pflag.FlagSet, args []string) error {
|
|
|
|
for _, id := range args {
|
|
|
|
if err := runUpdate(dockerCli, id, func(node *swarm.Node) {
|
|
|
|
node.Spec.Membership = swarm.NodeMembershipAccepted
|
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-06-17 10:49:35 -04:00
|
|
|
fmt.Fprintf(dockerCli.Out(), "Node %s accepted in the swarm.\n", id)
|
2016-06-13 22:56:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|