mirror of https://github.com/docker/cli.git
Handle networks.driver_opts for a service
These are endpoint-specific driver options... services: myservice: image: myimage networks: mynet: driver_opts: "option1": "value1" The API has had support for a long time, it's only recently been added to compose (unreleased right now). Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
parent
a731722652
commit
94f9de5928
|
@ -215,8 +215,10 @@ func convertServiceNetworks(
|
||||||
return nil, errors.Errorf("undefined network %q", networkName)
|
return nil, errors.Errorf("undefined network %q", networkName)
|
||||||
}
|
}
|
||||||
var aliases []string
|
var aliases []string
|
||||||
|
var driverOpts map[string]string
|
||||||
if network != nil {
|
if network != nil {
|
||||||
aliases = network.Aliases
|
aliases = network.Aliases
|
||||||
|
driverOpts = network.DriverOpts
|
||||||
}
|
}
|
||||||
target := namespace.Scope(networkName)
|
target := namespace.Scope(networkName)
|
||||||
if networkConfig.Name != "" {
|
if networkConfig.Name != "" {
|
||||||
|
@ -225,6 +227,7 @@ func convertServiceNetworks(
|
||||||
netAttachConfig := swarm.NetworkAttachmentConfig{
|
netAttachConfig := swarm.NetworkAttachmentConfig{
|
||||||
Target: target,
|
Target: target,
|
||||||
Aliases: aliases,
|
Aliases: aliases,
|
||||||
|
DriverOpts: driverOpts,
|
||||||
}
|
}
|
||||||
// Only add default aliases to user defined networks. Other networks do
|
// Only add default aliases to user defined networks. Other networks do
|
||||||
// not support aliases.
|
// not support aliases.
|
||||||
|
|
|
@ -240,6 +240,10 @@ func TestConvertServiceNetworks(t *testing.T) {
|
||||||
networks := map[string]*composetypes.ServiceNetworkConfig{
|
networks := map[string]*composetypes.ServiceNetworkConfig{
|
||||||
"front": {
|
"front": {
|
||||||
Aliases: []string{"something"},
|
Aliases: []string{"something"},
|
||||||
|
DriverOpts: map[string]string{
|
||||||
|
"driver.opt1": "optval1",
|
||||||
|
"driver.opt2": "optval2",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"back": {
|
"back": {
|
||||||
Aliases: []string{"other"},
|
Aliases: []string{"other"},
|
||||||
|
@ -257,6 +261,10 @@ func TestConvertServiceNetworks(t *testing.T) {
|
||||||
{
|
{
|
||||||
Target: "fronttier",
|
Target: "fronttier",
|
||||||
Aliases: []string{"something", "service"},
|
Aliases: []string{"something", "service"},
|
||||||
|
DriverOpts: map[string]string{
|
||||||
|
"driver.opt1": "optval1",
|
||||||
|
"driver.opt2": "optval2",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,9 @@ services:
|
||||||
aliases:
|
aliases:
|
||||||
- alias1
|
- alias1
|
||||||
- alias3
|
- alias3
|
||||||
|
driver_opts:
|
||||||
|
"driveropt1": "optval1"
|
||||||
|
"driveropt2": "optval2"
|
||||||
other-network:
|
other-network:
|
||||||
ipv4_address: 172.16.238.10
|
ipv4_address: 172.16.238.10
|
||||||
ipv6_address: 2001:3984:3989::10
|
ipv6_address: 2001:3984:3989::10
|
||||||
|
|
|
@ -190,6 +190,10 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
|
||||||
Aliases: []string{"alias1", "alias3"},
|
Aliases: []string{"alias1", "alias3"},
|
||||||
Ipv4Address: "",
|
Ipv4Address: "",
|
||||||
Ipv6Address: "",
|
Ipv6Address: "",
|
||||||
|
DriverOpts: map[string]string{
|
||||||
|
"driveropt1": "optval1",
|
||||||
|
"driveropt2": "optval2",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"other-network": {
|
"other-network": {
|
||||||
Ipv4Address: "172.16.238.10",
|
Ipv4Address: "172.16.238.10",
|
||||||
|
|
|
@ -285,7 +285,11 @@
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"alias1",
|
"alias1",
|
||||||
"alias3"
|
"alias3"
|
||||||
]
|
],
|
||||||
|
"driver_opts": {
|
||||||
|
"driveropt1": "optval1",
|
||||||
|
"driveropt2": "optval2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pid": "host",
|
"pid": "host",
|
||||||
|
|
|
@ -152,6 +152,9 @@ services:
|
||||||
aliases:
|
aliases:
|
||||||
- alias1
|
- alias1
|
||||||
- alias3
|
- alias3
|
||||||
|
driver_opts:
|
||||||
|
driveropt1: optval1
|
||||||
|
driveropt2: optval2
|
||||||
pid: host
|
pid: host
|
||||||
ports:
|
ports:
|
||||||
- mode: ingress
|
- mode: ingress
|
||||||
|
|
|
@ -197,6 +197,12 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"aliases": {"$ref": "#/definitions/list_of_strings"},
|
"aliases": {"$ref": "#/definitions/list_of_strings"},
|
||||||
|
"driver_opts": {
|
||||||
|
"type": "object",
|
||||||
|
"patternProperties": {
|
||||||
|
"^.+$": { "type": ["string", "number"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
"ipv4_address": {"type": "string"},
|
"ipv4_address": {"type": "string"},
|
||||||
"ipv6_address": {"type": "string"}
|
"ipv6_address": {"type": "string"}
|
||||||
},
|
},
|
||||||
|
|
|
@ -375,6 +375,7 @@ type PlacementPreferences struct {
|
||||||
// ServiceNetworkConfig is the network configuration for a service
|
// ServiceNetworkConfig is the network configuration for a service
|
||||||
type ServiceNetworkConfig struct {
|
type ServiceNetworkConfig struct {
|
||||||
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
|
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
|
||||||
|
DriverOpts map[string]string `mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
|
||||||
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
|
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
|
||||||
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
|
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue