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 5, 2017
1 parent 1a24524 commit 7d10d60
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 159 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 @@ -183,14 +183,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
30 changes: 29 additions & 1 deletion api/api.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4747,7 +4747,8 @@ file {
name: "isolation"
number: 24
label: LABEL_OPTIONAL
type: TYPE_STRING
type: TYPE_ENUM
type_name: ".docker.swarmkit.v1.ContainerSpec.Isolation"
json_name: "isolation"
}
nested_type {
Expand Down Expand Up @@ -4804,6 +4805,33 @@ file {
json_name: "options"
}
}
enum_type {
name: "Isolation"
value {
name: "ISOLATION_DEFAULT"
number: 0
options {
66001: "ContainerIsolationDefault"
}
}
value {
name: "ISOLATION_PROCESS"
number: 1
options {
66001: "ContainerIsolationProcess"
}
}
value {
name: "ISOLATION_HYPERV"
number: 2
options {
66001: "ContainerIsolationHyperV"
}
}
options {
62001: 0
}
}
}
message_type {
name: "EndpointSpec"
Expand Down
Loading

0 comments on commit 7d10d60

Please sign in to comment.