mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
0640a14b4f
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>
43 lines
947 B
Go
43 lines
947 B
Go
package network
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
"github.com/docker/docker/cli"
|
|
"github.com/docker/docker/cli/command"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "rm NETWORK [NETWORK...]",
|
|
Aliases: []string{"remove"},
|
|
Short: "Remove one or more networks",
|
|
Args: cli.RequiresMinArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runRemove(dockerCli, args)
|
|
},
|
|
}
|
|
}
|
|
|
|
func runRemove(dockerCli *command.DockerCli, networks []string) error {
|
|
client := dockerCli.Client()
|
|
ctx := context.Background()
|
|
status := 0
|
|
|
|
for _, name := range networks {
|
|
if err := client.NetworkRemove(ctx, name); err != nil {
|
|
fmt.Fprintf(dockerCli.Err(), "%s\n", err)
|
|
status = 1
|
|
continue
|
|
}
|
|
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
|
|
}
|
|
|
|
if status != 0 {
|
|
return cli.StatusError{StatusCode: status}
|
|
}
|
|
return nil
|
|
}
|