diff --git a/container_test.go b/container_test.go index a0008f35..cfbbcca4 100644 --- a/container_test.go +++ b/container_test.go @@ -61,4 +61,35 @@ func TestContainerJsonFormat(t *testing.T) { t.Log("capabilities mask should contain SYS_CHROOT") t.Fail() } + + for _, n := range container.Networks { + if n.Type == "veth" { + if n.Bridge != "docker0" { + t.Logf("veth bridge should be docker0 but received %q", n.Bridge) + t.Fail() + } + + if n.Address != "172.17.0.101/16" { + t.Logf("veth address should be 172.17.0.101/61 but received %q", n.Address) + t.Fail() + } + + if n.VethPrefix != "veth" { + t.Logf("veth prefix should be veth but received %q", n.VethPrefix) + t.Fail() + } + + if n.Gateway != "172.17.42.1" { + t.Logf("veth gateway should be 172.17.42.1 but received %q", n.Gateway) + t.Fail() + } + + if n.Mtu != 1500 { + t.Logf("veth mtu should be 1500 but received %d", n.Mtu) + t.Fail() + } + + break + } + } } diff --git a/network/types.go b/network/types.go index e4ebbb2b..14463ab7 100644 --- a/network/types.go +++ b/network/types.go @@ -15,7 +15,7 @@ type Network struct { Bridge string `json:"bridge,omitempty"` // Prefix for the veth interfaces. - VethPrefix string `json:"type,omitempty"` + VethPrefix string `json:"veth_prefix,omitempty"` // Address contains the IP and mask to set on the network interface Address string `json:"address,omitempty"` diff --git a/sample_configs/attach_to_bridge.json b/sample_configs/attach_to_bridge.json index da138d17..20547fe1 100644 --- a/sample_configs/attach_to_bridge.json +++ b/sample_configs/attach_to_bridge.json @@ -200,10 +200,8 @@ }, { "address": "172.17.0.101/16", - "context": { - "bridge": "docker0", - "prefix": "veth" - }, + "bridge": "docker0", + "veth_prefix": "veth", "gateway": "172.17.42.1", "mtu": 1500, "type": "veth"