Always use a default network if no other networks are set.
also add network labels. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
b0efbcc34a
commit
644d30369a
1 changed files with 14 additions and 2 deletions
|
@ -150,6 +150,9 @@ func createNetworks(
|
||||||
existingNetworkMap[network.Name] = network
|
existingNetworkMap[network.Name] = network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: only add default network if it's used
|
||||||
|
networks["default"] = composetypes.NetworkConfig{}
|
||||||
|
|
||||||
for internalName, network := range networks {
|
for internalName, network := range networks {
|
||||||
if network.External.Name != "" {
|
if network.External.Name != "" {
|
||||||
continue
|
continue
|
||||||
|
@ -161,8 +164,7 @@ func createNetworks(
|
||||||
}
|
}
|
||||||
|
|
||||||
createOpts := types.NetworkCreate{
|
createOpts := types.NetworkCreate{
|
||||||
// TODO: support network labels from compose file
|
Labels: getStackLabels(namespace, network.Labels),
|
||||||
Labels: getStackLabels(namespace, nil),
|
|
||||||
Driver: network.Driver,
|
Driver: network.Driver,
|
||||||
Options: network.DriverOpts,
|
Options: network.DriverOpts,
|
||||||
}
|
}
|
||||||
|
@ -191,6 +193,16 @@ func convertNetworks(
|
||||||
namespace string,
|
namespace string,
|
||||||
name string,
|
name string,
|
||||||
) []swarm.NetworkAttachmentConfig {
|
) []swarm.NetworkAttachmentConfig {
|
||||||
|
if len(networks) == 0 {
|
||||||
|
return []swarm.NetworkAttachmentConfig{
|
||||||
|
{
|
||||||
|
// TODO: only do this name mangling in one function
|
||||||
|
Target: namespace + "_" + "default",
|
||||||
|
Aliases: []string{name},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nets := []swarm.NetworkAttachmentConfig{}
|
nets := []swarm.NetworkAttachmentConfig{}
|
||||||
for networkName, network := range networks {
|
for networkName, network := range networks {
|
||||||
nets = append(nets, swarm.NetworkAttachmentConfig{
|
nets = append(nets, swarm.NetworkAttachmentConfig{
|
||||||
|
|
Loading…
Add table
Reference in a new issue