diff options
author | Brent Baude <bbaude@redhat.com> | 2020-02-03 15:30:17 -0600 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-02-03 15:30:17 -0600 |
commit | b438cb2cce33ac727f3b0c24154055e287fead4d (patch) | |
tree | ac4e9f8f8f9671d09e48fbfc2032fb9c56d8068b /cmd/podman/common.go | |
parent | 23f795786224c27f737e9043e9d513f54fa35ba8 (diff) | |
download | podman-b438cb2cce33ac727f3b0c24154055e287fead4d.tar.gz podman-b438cb2cce33ac727f3b0c24154055e287fead4d.tar.bz2 podman-b438cb2cce33ac727f3b0c24154055e287fead4d.zip |
seperate container create network options
this pr splits off some of the network container create options into a different flag set. the options in question are:
--add-host
--dns
--dns-opt
--dns-search
--ip
--mac-address
--network
--no-hosts
--publish
in the future, these options are going to be added to the pod create flags. this makes that transition easier and provides for less code duplication.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/common.go')
-rw-r--r-- | cmd/podman/common.go | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 46feae90d..7610edbc0 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -16,6 +16,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) var ( @@ -116,14 +117,49 @@ func getDefaultNetwork() string { return "bridge" } -func getCreateFlags(c *cliconfig.PodmanCommand) { - - createFlags := c.Flags() - - createFlags.StringSlice( +func getNetFlags() *pflag.FlagSet { + netFlags := pflag.FlagSet{} + netFlags.StringSlice( "add-host", []string{}, "Add a custom host-to-IP mapping (host:ip) (default [])", ) + netFlags.StringSlice( + "dns", []string{}, + "Set custom DNS servers", + ) + netFlags.StringSlice( + "dns-opt", []string{}, + "Set custom DNS options", + ) + netFlags.StringSlice( + "dns-search", []string{}, + "Set custom DNS search domains", + ) + netFlags.String( + "ip", "", + "Specify a static IPv4 address for the container", + ) + netFlags.String( + "mac-address", "", + "Container MAC address (e.g. 92:d0:c6:0a:29:33)", + ) + netFlags.String( + "network", getDefaultNetwork(), + "Connect a container to a network", + ) + netFlags.StringSliceP( + "publish", "p", []string{}, + "Publish a container's port, or a range of ports, to the host (default [])", + ) + netFlags.Bool( + "no-hosts", false, + "Do not create /etc/hosts within the container, instead use the version from the image", + ) + return &netFlags +} + +func getCreateFlags(c *cliconfig.PodmanCommand) { + createFlags := c.Flags() createFlags.StringSlice( "annotation", []string{}, "Add annotations to container (key:value) (default [])", @@ -236,18 +272,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "device-write-iops", []string{}, "Limit write rate (IO per second) to a device (e.g. --device-write-iops=/dev/sda:1000)", ) - createFlags.StringSlice( - "dns", []string{}, - "Set custom DNS servers", - ) - createFlags.StringSlice( - "dns-opt", []string{}, - "Set custom DNS options", - ) - createFlags.StringSlice( - "dns-search", []string{}, - "Set custom DNS search domains", - ) createFlags.String( "entrypoint", "", "Overwrite the default ENTRYPOINT of the image", @@ -324,10 +348,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "Keep STDIN open even if not attached", ) createFlags.String( - "ip", "", - "Specify a static IPv4 address for the container", - ) - createFlags.String( "ipc", "", "IPC namespace to use", ) @@ -351,10 +371,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "log-opt", []string{}, "Logging driver options (default [])", ) - createFlags.String( - "mac-address", "", - "Container MAC address (e.g. 92:d0:c6:0a:29:33)", - ) createFlags.StringP( "memory", "m", "", "Memory limit "+sizeWithUnitFormat, @@ -375,14 +391,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "name", "", "Assign a name to the container", ) - createFlags.String( - "network", getDefaultNetwork(), - "Connect a container to a network", - ) - createFlags.Bool( - "no-hosts", false, - "Do not create /etc/hosts within the container, instead use the version from the image", - ) createFlags.Bool( "oom-kill-disable", false, "Disable OOM Killer", @@ -417,10 +425,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "privileged", false, "Give extended privileges to container", ) - createFlags.StringSliceP( - "publish", "p", []string{}, - "Publish a container's port, or a range of ports, to the host (default [])", - ) createFlags.BoolP( "publish-all", "P", false, "Publish all exposed ports to random ports on the host interface", |