forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
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 containers#16732 from flouthoc/network-update
network: add support for `podman network update` and `--network-dns-server`
- Loading branch information
Showing
16 changed files
with
320 additions
and
16 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
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,57 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/containers/common/pkg/completion" | ||
"github.com/containers/podman/v4/cmd/podman/common" | ||
"github.com/containers/podman/v4/cmd/podman/registry" | ||
"github.com/containers/podman/v4/pkg/domain/entities" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
networkUpdateDescription = `Update an existing podman network` | ||
networkUpdateCommand = &cobra.Command{ | ||
Use: "update [options] NETWORK", | ||
Short: "update an existing podman network", | ||
Long: networkUpdateDescription, | ||
RunE: networkUpdate, | ||
Args: cobra.ExactArgs(1), | ||
ValidArgsFunction: common.AutocompleteNetworks, | ||
Example: `podman network update podman1`, | ||
} | ||
) | ||
|
||
var ( | ||
networkUpdateOptions entities.NetworkUpdateOptions | ||
) | ||
|
||
func networkUpdateFlags(cmd *cobra.Command) { | ||
flags := cmd.Flags() | ||
|
||
addDNSServerFlagName := "dns-add" | ||
flags.StringArrayVar(&networkUpdateOptions.AddDNSServers, addDNSServerFlagName, nil, "add network level nameservers") | ||
removeDNSServerFlagName := "dns-drop" | ||
flags.StringArrayVar(&networkUpdateOptions.RemoveDNSServers, removeDNSServerFlagName, nil, "remove network level nameservers") | ||
_ = cmd.RegisterFlagCompletionFunc(addDNSServerFlagName, completion.AutocompleteNone) | ||
_ = cmd.RegisterFlagCompletionFunc(removeDNSServerFlagName, completion.AutocompleteNone) | ||
} | ||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Command: networkUpdateCommand, | ||
Parent: networkCmd, | ||
}) | ||
networkUpdateFlags(networkUpdateCommand) | ||
} | ||
|
||
func networkUpdate(cmd *cobra.Command, args []string) error { | ||
name := args[0] | ||
|
||
err := registry.ContainerEngine().NetworkUpdate(registry.Context(), name, networkUpdateOptions) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(name) | ||
return nil | ||
} |
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,36 @@ | ||
% podman-network-update 1 | ||
|
||
## NAME | ||
podman\-network\-update - Update an existing Podman network | ||
|
||
## SYNOPSIS | ||
**podman network update** [*options*] *network* | ||
|
||
## DESCRIPTION | ||
Allow changes to existing container networks. At present, only changes to the DNS servers in use by a network is supported. | ||
|
||
NOTE: Only supported with the netavark network backend. | ||
|
||
|
||
## OPTIONS | ||
#### **--dns-add** | ||
|
||
Accepts array of DNS resolvers and add it to the existing list of resolvers configured for a network. | ||
|
||
#### **--dns-drop** | ||
|
||
Accepts array of DNS resolvers and removes them from the existing list of resolvers configured for a network. | ||
|
||
## EXAMPLE | ||
|
||
Update a network | ||
``` | ||
$ podman network update network1 --dns-add 8.8.8.8,1.1.1.1 | ||
``` | ||
|
||
Update a network and add/remove dns servers | ||
``` | ||
$ podman network update network1 --dns-drop 8.8.8.8 --dns-add 3.3.3.3 | ||
``` | ||
## SEE ALSO | ||
**[podman(1)](podman.1.md)**, **[podman-network(1)](podman-network.1.md)**, **[podman-network-inspect(1)](podman-network-inspect.1.md)**, **[podman-network-ls(1)](podman-network-ls.1.md)** |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.