Skip to content

Commit

Permalink
Use an enum for isolation
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
  • Loading branch information
simonferquel committed Oct 2, 2017
1 parent d62fb55 commit 6b6688f
Show file tree
Hide file tree
Showing 5 changed files with 10,006 additions and 157 deletions.
10 changes: 9 additions & 1 deletion agent/exec/dockerapi/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ func (c *containerConfig) portBindings() nat.PortMap {
}

func (c *containerConfig) isolation() enginecontainer.Isolation {
return enginecontainer.Isolation(c.spec().Isolation)
switch c.spec().Isolation {
case api.ContainerIsolationDefault:
return enginecontainer.Isolation("default")
case api.ContainerIsolationHyperV:
return enginecontainer.Isolation("hyperv")
case api.ContainerIsolationProcess:
return enginecontainer.Isolation("process")
}
return enginecontainer.Isolation("")
}

func (c *containerConfig) exposedPorts() map[nat.Port]struct{} {
Expand Down
4 changes: 2 additions & 2 deletions agent/exec/dockerapi/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ func TestIsolation(t *testing.T) {
Spec: api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Isolation: "test",
Isolation: api.ContainerIsolationHyperV,
},
},
},
},
}

expected := "test"
expected := "hyperv"
actual := string(c.hostConfig().Isolation)
if actual != expected {
t.Fatalf("expected %s, got %s", expected, actual)
Expand Down
Loading

0 comments on commit 6b6688f

Please sign in to comment.