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
13 changed files
with
189 additions
and
12 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,64 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
|
||
//"github.com/containers/common/libnetwork/types" | ||
"github.com/containers/common/pkg/completion" | ||
//"github.com/containers/podman/v4/cmd/podman/common" | ||
//"github.com/containers/podman/v4/cmd/podman/parse" | ||
"github.com/containers/podman/v4/cmd/podman/registry" | ||
"github.com/containers/podman/v4/pkg/domain/entities" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
networkUpdateDescription = `update networks for containers and pods` | ||
networkUpdateCommand = &cobra.Command{ | ||
Use: "update [options] [NAME]", | ||
Short: "network update", | ||
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] | ||
} | ||
|
||
fmt.Printf("----network update command %+v %+v\n", networkUpdateOptions, name) | ||
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
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.
74 changes: 65 additions & 9 deletions
74
vendor/github.com/containers/common/libnetwork/netavark/config.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
vendor/github.com/containers/common/libnetwork/netavark/run.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
vendor/github.com/containers/common/libnetwork/types/network.go
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