mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #30742 from yongtang/29975-compose-network-attachable
Add compose support of `attachable` in networks
This commit is contained in:
commit
e06ae6f419
6 changed files with 50 additions and 9 deletions
|
@ -65,6 +65,7 @@ func Networks(namespace Namespace, networks networkMap, servicesNetworks map[str
|
||||||
Driver: network.Driver,
|
Driver: network.Driver,
|
||||||
Options: network.DriverOpts,
|
Options: network.DriverOpts,
|
||||||
Internal: network.Internal,
|
Internal: network.Internal,
|
||||||
|
Attachable: network.Attachable,
|
||||||
}
|
}
|
||||||
|
|
||||||
if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
|
if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestNetworks(t *testing.T) {
|
||||||
"normal": {},
|
"normal": {},
|
||||||
"outside": {},
|
"outside": {},
|
||||||
"default": {},
|
"default": {},
|
||||||
|
"attachablenet": {},
|
||||||
}
|
}
|
||||||
source := networkMap{
|
source := networkMap{
|
||||||
"normal": composetypes.NetworkConfig{
|
"normal": composetypes.NetworkConfig{
|
||||||
|
@ -58,6 +59,10 @@ func TestNetworks(t *testing.T) {
|
||||||
Name: "special",
|
Name: "special",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"attachablenet": composetypes.NetworkConfig{
|
||||||
|
Driver: "overlay",
|
||||||
|
Attachable: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
expected := map[string]types.NetworkCreate{
|
expected := map[string]types.NetworkCreate{
|
||||||
"default": {
|
"default": {
|
||||||
|
@ -83,6 +88,13 @@ func TestNetworks(t *testing.T) {
|
||||||
"something": "labeled",
|
"something": "labeled",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"attachablenet": {
|
||||||
|
Driver: "overlay",
|
||||||
|
Attachable: true,
|
||||||
|
Labels: map[string]string{
|
||||||
|
LabelNamespace: "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
networks, externals := Networks(namespace, source, serviceNetworks)
|
networks, externals := Networks(namespace, source, serviceNetworks)
|
||||||
|
|
|
@ -799,3 +799,29 @@ type servicesByName []types.ServiceConfig
|
||||||
func (sbn servicesByName) Len() int { return len(sbn) }
|
func (sbn servicesByName) Len() int { return len(sbn) }
|
||||||
func (sbn servicesByName) Swap(i, j int) { sbn[i], sbn[j] = sbn[j], sbn[i] }
|
func (sbn servicesByName) Swap(i, j int) { sbn[i], sbn[j] = sbn[j], sbn[i] }
|
||||||
func (sbn servicesByName) Less(i, j int) bool { return sbn[i].Name < sbn[j].Name }
|
func (sbn servicesByName) Less(i, j int) bool { return sbn[i].Name < sbn[j].Name }
|
||||||
|
|
||||||
|
func TestLoadAttachableNetwork(t *testing.T) {
|
||||||
|
config, err := loadYAML(`
|
||||||
|
version: "3.1"
|
||||||
|
networks:
|
||||||
|
mynet1:
|
||||||
|
driver: overlay
|
||||||
|
attachable: true
|
||||||
|
mynet2:
|
||||||
|
driver: bridge
|
||||||
|
`)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
expected := map[string]types.NetworkConfig{
|
||||||
|
"mynet1": {
|
||||||
|
Driver: "overlay",
|
||||||
|
Attachable: true,
|
||||||
|
},
|
||||||
|
"mynet2": {
|
||||||
|
Driver: "bridge",
|
||||||
|
Attachable: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, expected, config.Networks)
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -338,6 +338,7 @@
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"internal": {"type": "boolean"},
|
"internal": {"type": "boolean"},
|
||||||
|
"attachable": {"type": "boolean"},
|
||||||
"labels": {"$ref": "#/definitions/list_or_dict"}
|
"labels": {"$ref": "#/definitions/list_or_dict"}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
@ -238,6 +238,7 @@ type NetworkConfig struct {
|
||||||
Ipam IPAMConfig
|
Ipam IPAMConfig
|
||||||
External External
|
External External
|
||||||
Internal bool
|
Internal bool
|
||||||
|
Attachable bool
|
||||||
Labels MappingWithEquals
|
Labels MappingWithEquals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue