1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/cli/command/network/disconnect.go
Daniel Nephin 0640a14b4f Move api/client -> cli/command
Using
  gomvpkg
     -from github.com/docker/docker/api/client
     -to github.com/docker/docker/cli/command
     -vcs_mv_cmd 'git mv {{.Src}} {{.Dst}}'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2016-09-08 15:46:29 -04:00

41 lines
1,009 B
Go

package network
import (
"golang.org/x/net/context"
"github.com/docker/docker/cli"
"github.com/docker/docker/cli/command"
"github.com/spf13/cobra"
)
type disconnectOptions struct {
network string
container string
force bool
}
func newDisconnectCommand(dockerCli *command.DockerCli) *cobra.Command {
opts := disconnectOptions{}
cmd := &cobra.Command{
Use: "disconnect [OPTIONS] NETWORK CONTAINER",
Short: "Disconnect a container from a network",
Args: cli.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
opts.network = args[0]
opts.container = args[1]
return runDisconnect(dockerCli, opts)
},
}
flags := cmd.Flags()
flags.BoolVarP(&opts.force, "force", "f", false, "Force the container to disconnect from a network")
return cmd
}
func runDisconnect(dockerCli *command.DockerCli, opts disconnectOptions) error {
client := dockerCli.Client()
return client.NetworkDisconnect(context.Background(), opts.network, opts.container, opts.force)
}