Skip to content

Commit 94bd735

Browse files
robmryglours
authored andcommitted
Add driver_opts to services.networks
Signed-off-by: Rob Murray <[email protected]>
1 parent 2bbabf1 commit 94bd735

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

loader/loader_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,49 @@ networks:
17271727
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
17281728
}
17291729

1730+
func TestLoadServiceNetworkDriverOpts(t *testing.T) {
1731+
config, err := loadYAML(`
1732+
name: load-service-network-driver-opts
1733+
services:
1734+
foo:
1735+
image: alpine
1736+
networks:
1737+
network1:
1738+
driver_opts:
1739+
com.docker.network.endpoint.sysctls: "ipv6.conf.accept_ra=0"
1740+
networks:
1741+
network1:
1742+
`)
1743+
assert.NilError(t, err)
1744+
1745+
workingDir, err := os.Getwd()
1746+
assert.NilError(t, err)
1747+
expected := &types.Project{
1748+
Name: "load-service-network-driver-opts",
1749+
WorkingDir: workingDir,
1750+
Services: types.Services{
1751+
"foo": {
1752+
Name: "foo",
1753+
Image: "alpine",
1754+
Networks: map[string]*types.ServiceNetworkConfig{
1755+
"network1": {
1756+
DriverOpts: types.Options{
1757+
"com.docker.network.endpoint.sysctls": "ipv6.conf.accept_ra=0",
1758+
},
1759+
},
1760+
},
1761+
},
1762+
},
1763+
Networks: map[string]types.NetworkConfig{
1764+
"network1": {},
1765+
},
1766+
Environment: types.Mapping{
1767+
"COMPOSE_PROJECT_NAME": "load-service-network-driver-opts",
1768+
},
1769+
}
1770+
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
1771+
}
1772+
17301773
func TestLoadInit(t *testing.T) {
17311774
booleanTrue := true
17321775
booleanFalse := false

schema/compose-spec.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@
296296
"ipv6_address": {"type": "string"},
297297
"link_local_ips": {"$ref": "#/definitions/list_of_strings"},
298298
"mac_address": {"type": "string"},
299+
"driver_opts": {
300+
"type": "object",
301+
"patternProperties": {
302+
"^.+$": {"type": ["string", "number"]}
303+
}
304+
},
299305
"priority": {"type": "number"}
300306
},
301307
"additionalProperties": false,

types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ type ServiceNetworkConfig struct {
453453
Ipv6Address string `yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
454454
LinkLocalIPs []string `yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty"`
455455
MacAddress string `yaml:"mac_address,omitempty" json:"mac_address,omitempty"`
456+
DriverOpts Options `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
456457

457458
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
458459
}

0 commit comments

Comments
 (0)