Skip to content

Commit

Permalink
allow passed in network namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Jun 29, 2020
1 parent b6e24d0 commit abd221f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ var (
SendSignals: false,
Exec: false,
FSIsolation: drivers.FSIsolationNone,
NetIsolationModes: []drivers.NetIsolationMode{
drivers.NetIsolationModeGroup,
drivers.NetIsolationModeHost,
drivers.NetIsolationModeTask,
},
MustInitiateNetwork: false,
}
)

Expand Down Expand Up @@ -370,6 +376,15 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
swap = driverConfig.MemorySwap
}

// Generate network string
var network string
if cfg.NetworkIsolation != nil &&
cfg.NetworkIsolation.Path != "" {
network = fmt.Sprintf("ns:%s", cfg.NetworkIsolation.Path)
} else {
network = driverConfig.NetworkMode
}

createOpts := iopodman.Create{
Args: allArgs,
Env: &allEnv,
Expand All @@ -385,7 +400,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
MemoryReservation: &driverConfig.MemoryReservation,
MemorySwap: &swap,
MemorySwappiness: &driverConfig.MemorySwappiness,
Network: &driverConfig.NetworkMode,
Network: &network,
Tmpfs: &driverConfig.Tmpfs,
}

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tk
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v0.12.1 h1:99niEVkDqsEv3/jINwoOUgGE9L41LHXM4k3jTkV+DdA=
github.com/hashicorp/go-hclog v0.12.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.1.0 h1:vN9wG1D6KG6YHRTWr8512cxGOVgTMEfgEdSj/hr8MPc=
Expand Down

0 comments on commit abd221f

Please sign in to comment.