-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8391 from baude/networkconnectdisconnect
add network connect|disconnect compat endpoints
- Loading branch information
Showing
23 changed files
with
651 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package network | ||
|
||
import ( | ||
"github.com/containers/common/pkg/completion" | ||
"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" | ||
) | ||
|
||
var ( | ||
networkConnectDescription = `Add container to a network` | ||
networkConnectCommand = &cobra.Command{ | ||
Use: "connect [options] NETWORK CONTAINER", | ||
Short: "network connect", | ||
Long: networkConnectDescription, | ||
RunE: networkConnect, | ||
Example: `podman network connect web secondary`, | ||
Args: cobra.ExactArgs(2), | ||
ValidArgsFunction: common.AutocompleteNetworks, | ||
} | ||
) | ||
|
||
var ( | ||
networkConnectOptions entities.NetworkConnectOptions | ||
) | ||
|
||
func networkConnectFlags(cmd *cobra.Command) { | ||
flags := cmd.Flags() | ||
aliasFlagName := "alias" | ||
flags.StringSliceVar(&networkConnectOptions.Aliases, aliasFlagName, []string{}, "network scoped alias for container") | ||
_ = cmd.RegisterFlagCompletionFunc(aliasFlagName, completion.AutocompleteNone) | ||
} | ||
|
||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, | ||
Command: networkConnectCommand, | ||
Parent: networkCmd, | ||
}) | ||
networkConnectFlags(networkConnectCommand) | ||
} | ||
|
||
func networkConnect(cmd *cobra.Command, args []string) error { | ||
networkConnectOptions.Container = args[1] | ||
return registry.ContainerEngine().NetworkConnect(registry.Context(), args[0], networkConnectOptions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
% podman-network-connect(1) | ||
|
||
## NAME | ||
podman\-network\-connect - Connect a container to a network | ||
|
||
## SYNOPSIS | ||
**podman network connect** [*options*] network container | ||
|
||
## DESCRIPTION | ||
Connects a container to a network. A container can be connected to a network by name or by ID. | ||
Once connected, the container can communicate with other containers in the same network. | ||
|
||
## OPTIONS | ||
#### **--alias** | ||
Add network-scoped alias for the container. If the network is using the `dnsname` CNI plugin, these aliases | ||
can be used for name resolution on the given network. Multiple *--alias* options may be specificed as input. | ||
|
||
## EXAMPLE | ||
|
||
Connect a container named *web* to a network named *test* | ||
``` | ||
podman network connect test web | ||
``` | ||
|
||
Connect a container name *web* to a network named *test* with two aliases: web1 and web2 | ||
``` | ||
podman network connect --alias web1 --alias web2 test web | ||
``` | ||
|
||
## SEE ALSO | ||
podman(1), podman-network(1), podman-network-disconnect(1), podman-network-inspect(1) | ||
|
||
## HISTORY | ||
November 2020, Originally compiled by Brent Baude <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
% podman-network-disconnect(1) | ||
|
||
## NAME | ||
podman\-network\-disconnect - Disconnect a container from a network | ||
|
||
## SYNOPSIS | ||
**podman network disconnect** [*options*] network container | ||
|
||
## DESCRIPTION | ||
Disconnects a container from a network. | ||
|
||
## OPTIONS | ||
#### **--force**, **-f** | ||
|
||
Force the container to disconnect from a network | ||
|
||
## EXAMPLE | ||
Disconnect a container named *web* from a network called *test*. | ||
|
||
``` | ||
podman network disconnect test web | ||
``` | ||
|
||
|
||
## SEE ALSO | ||
podman(1), podman-network(1), podman-network-connect(1) | ||
|
||
## HISTORY | ||
November 2020, Originally compiled by Brent Baude <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.