forked from containers/podman
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network: add support for podman network update and --network-dns-server
* Add support for `podman network update <>` ```console network update Description: update networks for containers and pods Usage: podman network update [options] [NAME] Examples: podman network update podman1 Options: --add-dns-servers stringArray add network level nameservers --remove-dns-servers stringArray remove network level nameservers ``` * Add support for `--network-dns-server` to `podman network create` Extends podman to support recently added features in `netavark` and `aardvark-dns` * containers/netavark#497 * containers/aardvark-dns#252 * containers/netavark#503 [NO NEW TESTS NEEDED] [NO TESTS NEEDED] Signed-off-by: Aditya R <arajan@redhat.com>
- Loading branch information
Showing
23 changed files
with
361 additions
and
49 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,58 @@ | ||
package network | ||
|
||
import ( | ||
"github.com/containers/common/pkg/completion" | ||
"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] [NAME]", | ||
Short: "update an existing podman network", | ||
Long: networkUpdateDescription, | ||
RunE: networkUpdate, | ||
Args: cobra.MaximumNArgs(1), | ||
ValidArgsFunction: completion.AutocompleteNone, | ||
Example: `podman network update podman1`, | ||
} | ||
) | ||
|
||
var ( | ||
networkUpdateOptions entities.NetworkUpdateOptions | ||
) | ||
|
||
func networkUpdateFlags(cmd *cobra.Command) { | ||
flags := cmd.Flags() | ||
|
||
addDNSServerFlagName := "add-dns-servers" | ||
flags.StringArrayVar(&networkUpdateOptions.AddDNSServers, addDNSServerFlagName, nil, "add network level nameservers") | ||
removeDNSServerFlagName := "remove-dns-servers" | ||
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 { | ||
var ( | ||
name string | ||
) | ||
if len(args) > 0 { | ||
name = args[0] | ||
} | ||
|
||
err := registry.ContainerEngine().NetworkUpdate(registry.Context(), name, networkUpdateOptions) | ||
if err != nil { | ||
return err | ||
} | ||
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,25 @@ | ||
% podman-network-update 1 | ||
|
||
## NAME | ||
podman\-network-update - Update an existing podman network | ||
|
||
## SYNOPSIS | ||
**podman network update** [*options*] [*name*] | ||
|
||
## DESCRIPTION | ||
Allows end users to update network scoped DNS resolvers for an existing podman network. | ||
|
||
NOTE: Only supported with netavark and aardvark-dns | ||
|
||
|
||
## OPTIONS | ||
#### **--add-dns-servers** | ||
|
||
Accepts array of DNS resolvers and add it to the existing list of resolvers configured for a network. | ||
|
||
#### **--remove-dns-servers** | ||
|
||
Accepts array of DNS resolvers and removes them from the existing list of resolvers configured for a network. | ||
|
||
## 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
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.