mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not panic if network is nil
network is `nil` if the following case:
```
services:
foo:
image: nginx
networks:
mynetwork:
```
It's a valid compose so we should not panic.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
(cherry picked from commit 158388ef8d
)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
040d4ebd58
commit
05eb544ae2
1 changed files with 5 additions and 1 deletions
|
@ -252,9 +252,13 @@ func convertServiceNetworks(
|
||||||
|
|
||||||
nets := []swarm.NetworkAttachmentConfig{}
|
nets := []swarm.NetworkAttachmentConfig{}
|
||||||
for networkName, network := range networks {
|
for networkName, network := range networks {
|
||||||
|
var aliases []string
|
||||||
|
if network != nil {
|
||||||
|
aliases = network.Aliases
|
||||||
|
}
|
||||||
nets = append(nets, swarm.NetworkAttachmentConfig{
|
nets = append(nets, swarm.NetworkAttachmentConfig{
|
||||||
Target: namespace.scope(networkName),
|
Target: namespace.scope(networkName),
|
||||||
Aliases: append(network.Aliases, name),
|
Aliases: append(aliases, name),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return nets
|
return nets
|
||||||
|
|
Loading…
Add table
Reference in a new issue