Change network to a boolean

This commit is contained in:
Donny Xia
2020-09-16 16:20:50 -07:00
parent 76bae738a0
commit f6c06b58ef
6 changed files with 129 additions and 43 deletions

View File

@@ -154,13 +154,17 @@ func (c *Filter) setupExec() {
// getArgs returns the command + args to run to spawn the container
func (c *Filter) getCommand() (string, []string) {
network := runtimeutil.NetworkNameNone
if c.ContainerSpec.Network {
network = runtimeutil.NetworkNameHost
}
// run the container using docker. this is simpler than using the docker
// libraries, and ensures things like auth work the same as if the container
// was run from the cli.
args := []string{"run",
"--rm", // delete the container afterward
"-i", "-a", "STDIN", "-a", "STDOUT", "-a", "STDERR", // attach stdin, stdout, stderr
"--network", string(c.ContainerSpec.Network.Name),
"--network", string(network),
// added security options
"--user", c.User.String(),
@@ -186,10 +190,5 @@ func NewContainer(spec runtimeutil.ContainerSpec) Filter {
f.ContainerSpec.User = runtimeutil.UserNobody
}
// default network name is none
if f.ContainerSpec.Network.Name == "" {
f.ContainerSpec.Network.Name = runtimeutil.NetworkNameNone
}
return f
}