Remove c.String(net)

We have a lot of cludgy code trying to make --net and --network equivalent.
This will allow --net to still exists but will eliminate the help and confusion.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-01-14 18:55:20 -05:00
parent 61fbce710b
commit 45e9a6b12e
11 changed files with 8 additions and 31 deletions

2
API.md
View File

@ -1587,8 +1587,6 @@ memorySwappiness [?int](#?int)
name [?string](#?string) name [?string](#?string)
net [?string](#?string)
network [?string](#?string) network [?string](#?string)
noHosts [?bool](#?bool) noHosts [?bool](#?bool)

View File

@ -375,10 +375,6 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"name", "", "name", "",
"Assign a name to the container", "Assign a name to the container",
) )
createFlags.String(
"net", getDefaultNetwork(),
"Connect a container to a network",
)
createFlags.String( createFlags.String(
"network", getDefaultNetwork(), "network", getDefaultNetwork(),
"Connect a container to a network", "Connect a container to a network",

View File

@ -85,13 +85,7 @@ func createInit(c *cliconfig.PodmanCommand) error {
logrus.Warn("setting security options with --privileged has no effect") logrus.Warn("setting security options with --privileged has no effect")
} }
var setNet string if (c.IsSet("dns") || c.IsSet("dns-opt") || c.IsSet("dns-search")) && (c.String("network") == "none" || strings.HasPrefix(c.String("network"), "container:")) {
if c.IsSet("network") {
setNet = c.String("network")
} else if c.IsSet("net") {
setNet = c.String("net")
}
if (c.IsSet("dns") || c.IsSet("dns-opt") || c.IsSet("dns-search")) && (setNet == "none" || strings.HasPrefix(setNet, "container:")) {
return errors.Errorf("conflicting options: dns and the network mode.") return errors.Errorf("conflicting options: dns and the network mode.")
} }

View File

@ -25,7 +25,7 @@ var (
return runCmd(&runCommand) return runCmd(&runCommand)
}, },
Example: `podman run imageID ls -alF /etc Example: `podman run imageID ls -alF /etc
podman run --net=host imageID dnf -y install java podman run --network=host imageID dnf -y install java
podman run --volume /var/hostdir:/var/ctrdir -i -t fedora /bin/bash`, podman run --volume /var/hostdir:/var/ctrdir -i -t fedora /bin/bash`,
} }
) )

View File

@ -355,14 +355,10 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
// Instead of integrating here, should be done in libpod // Instead of integrating here, should be done in libpod
// However, that also involves setting up security opts // However, that also involves setting up security opts
// when the pod's namespace is integrated // when the pod's namespace is integrated
namespaceNet := c.String("network")
if c.Changed("net") {
namespaceNet = c.String("net")
}
namespaces = map[string]string{ namespaces = map[string]string{
"cgroup": c.String("cgroupns"), "cgroup": c.String("cgroupns"),
"pid": c.String("pid"), "pid": c.String("pid"),
"net": namespaceNet, "net": c.String("network"),
"ipc": c.String("ipc"), "ipc": c.String("ipc"),
"user": c.String("userns"), "user": c.String("userns"),
"uts": c.String("uts"), "uts": c.String("uts"),
@ -636,11 +632,6 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
} }
// This is done because cobra cannot have two aliased flags. So we have to check // This is done because cobra cannot have two aliased flags. So we have to check
// both // both
network := c.String("network")
if c.Changed("net") {
network = c.String("net")
}
memorySwappiness := c.Int64("memory-swappiness") memorySwappiness := c.Int64("memory-swappiness")
logDriver := libpod.KubernetesLogging logDriver := libpod.KubernetesLogging
@ -687,7 +678,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
DNSServers: c.StringSlice("dns"), DNSServers: c.StringSlice("dns"),
HTTPProxy: c.Bool("http-proxy"), HTTPProxy: c.Bool("http-proxy"),
MacAddress: c.String("mac-address"), MacAddress: c.String("mac-address"),
Network: network, Network: c.String("network"),
NetMode: netMode, NetMode: netMode,
IPAddress: c.String("ip"), IPAddress: c.String("ip"),
Publish: c.StringSlice("publish"), Publish: c.StringSlice("publish"),

View File

@ -423,7 +423,6 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes
m["memory-swap"] = newCRString(c, "memory-swap") m["memory-swap"] = newCRString(c, "memory-swap")
m["memory-swappiness"] = newCRInt64(c, "memory-swappiness") m["memory-swappiness"] = newCRInt64(c, "memory-swappiness")
m["name"] = newCRString(c, "name") m["name"] = newCRString(c, "name")
m["net"] = newCRString(c, "net")
m["network"] = newCRString(c, "network") m["network"] = newCRString(c, "network")
m["no-hosts"] = newCRBool(c, "no-hosts") m["no-hosts"] = newCRBool(c, "no-hosts")
m["oom-kill-disable"] = newCRBool(c, "oom-kill-disable") m["oom-kill-disable"] = newCRBool(c, "oom-kill-disable")

View File

@ -127,7 +127,6 @@ func (g GenericCLIResults) MakeVarlink() iopodman.Create {
MemorySwap: StringToPtr(g.Find("memory-swap")), MemorySwap: StringToPtr(g.Find("memory-swap")),
MemorySwappiness: AnyIntToInt64Ptr(g.Find("memory-swappiness")), MemorySwappiness: AnyIntToInt64Ptr(g.Find("memory-swappiness")),
Name: StringToPtr(g.Find("name")), Name: StringToPtr(g.Find("name")),
Net: StringToPtr(g.Find("net")),
Network: StringToPtr(g.Find("network")), Network: StringToPtr(g.Find("network")),
OomKillDisable: BoolToPtr(g.Find("oom-kill-disable")), OomKillDisable: BoolToPtr(g.Find("oom-kill-disable")),
OomScoreAdj: AnyIntToInt64Ptr(g.Find("oom-score-adj")), OomScoreAdj: AnyIntToInt64Ptr(g.Find("oom-score-adj")),
@ -386,7 +385,6 @@ func VarlinkCreateToGeneric(opts iopodman.Create) GenericCLIResults {
m["memory-swap"] = stringFromVarlink(opts.MemorySwap, "memory-swap", nil) m["memory-swap"] = stringFromVarlink(opts.MemorySwap, "memory-swap", nil)
m["memory-swappiness"] = int64FromVarlink(opts.MemorySwappiness, "memory-swappiness", &memSwapDefault) m["memory-swappiness"] = int64FromVarlink(opts.MemorySwappiness, "memory-swappiness", &memSwapDefault)
m["name"] = stringFromVarlink(opts.Name, "name", nil) m["name"] = stringFromVarlink(opts.Name, "name", nil)
m["net"] = stringFromVarlink(opts.Net, "net", &netModeDefault)
m["network"] = stringFromVarlink(opts.Network, "network", &netModeDefault) m["network"] = stringFromVarlink(opts.Network, "network", &netModeDefault)
m["no-hosts"] = boolFromVarlink(opts.NoHosts, "no-hosts", false) m["no-hosts"] = boolFromVarlink(opts.NoHosts, "no-hosts", false)
m["oom-kill-disable"] = boolFromVarlink(opts.OomKillDisable, "oon-kill-disable", false) m["oom-kill-disable"] = boolFromVarlink(opts.OomKillDisable, "oon-kill-disable", false)

View File

@ -61,6 +61,8 @@ func aliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
name = "health-start-period" name = "health-start-period"
case "healthcheck-timeout": case "healthcheck-timeout":
name = "health-timeout" name = "health-timeout"
case "net":
name = "network"
} }
return pflag.NormalizedName(name) return pflag.NormalizedName(name)
} }

View File

@ -350,7 +350,6 @@ type Create (
memorySwap: ?string, memorySwap: ?string,
memorySwappiness: ?int, memorySwappiness: ?int,
name: ?string, name: ?string,
net: ?string,
network: ?string, network: ?string,
noHosts: ?bool, noHosts: ?bool,
oomKillDisable: ?bool, oomKillDisable: ?bool,

View File

@ -1014,7 +1014,7 @@ In order for users to run rootless, there must be an entry for their username in
Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed. Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed.
The fuse-overlay package provides a userspace overlay storage driver, otherwise users need to use The fuse-overlay package provides a userspace overlay storage driver, otherwise users need to use
the vfs storage driver, which is diskspace expensive and does not perform well. slirp4netns is the vfs storage driver, which is diskspace expensive and does not perform well. slirp4netns is
required for VPN, without it containers need to be run with the --net=host flag. required for VPN, without it containers need to be run with the --network=host flag.
## ENVIRONMENT ## ENVIRONMENT

View File

@ -1310,7 +1310,7 @@ In order for users to run rootless, there must be an entry for their username in
Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed. Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed.
The fuse-overlay package provides a userspace overlay storage driver, otherwise users need to use The fuse-overlay package provides a userspace overlay storage driver, otherwise users need to use
the vfs storage driver, which is diskspace expensive and does not perform well. slirp4netns is the vfs storage driver, which is diskspace expensive and does not perform well. slirp4netns is
required for VPN, without it containers need to be run with the --net=host flag. required for VPN, without it containers need to be run with the --network=host flag.
## ENVIRONMENT ## ENVIRONMENT