diff options
Diffstat (limited to 'cmd/podman/networks/disconnect.go')
-rw-r--r-- | cmd/podman/networks/disconnect.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cmd/podman/networks/disconnect.go b/cmd/podman/networks/disconnect.go new file mode 100644 index 000000000..598c23a1c --- /dev/null +++ b/cmd/podman/networks/disconnect.go @@ -0,0 +1,45 @@ +package network + +import ( + "github.com/containers/podman/v2/cmd/podman/common" + "github.com/containers/podman/v2/cmd/podman/registry" + "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +var ( + networkDisconnectDescription = `Remove container from a network` + networkDisconnectCommand = &cobra.Command{ + Use: "disconnect [options] NETWORK CONTAINER", + Short: "network rm", + Long: networkDisconnectDescription, + RunE: networkDisconnect, + Example: `podman network disconnect web secondary`, + Args: cobra.ExactArgs(2), + ValidArgsFunction: common.AutocompleteNetworks, + } +) + +var ( + networkDisconnectOptions entities.NetworkDisconnectOptions +) + +func networkDisconnectFlags(flags *pflag.FlagSet) { + flags.BoolVarP(&networkDisconnectOptions.Force, "force", "f", false, "force removal of container from network") +} + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, + Command: networkDisconnectCommand, + Parent: networkCmd, + }) + flags := networkDisconnectCommand.Flags() + networkDisconnectFlags(flags) +} + +func networkDisconnect(cmd *cobra.Command, args []string) error { + networkDisconnectOptions.Container = args[1] + return registry.ContainerEngine().NetworkDisconnect(registry.Context(), args[0], networkDisconnectOptions) +} |