Browse code

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>

Vincent Demeester authored on 2016/11/22 01:59:29
Showing 1 changed files
... ...
@@ -252,9 +252,13 @@ func convertServiceNetworks(
252 252
 
253 253
 	nets := []swarm.NetworkAttachmentConfig{}
254 254
 	for networkName, network := range networks {
255
+		var aliases []string
256
+		if network != nil {
257
+			aliases = network.Aliases
258
+		}
255 259
 		nets = append(nets, swarm.NetworkAttachmentConfig{
256 260
 			Target:  namespace.scope(networkName),
257
-			Aliases: append(network.Aliases, name),
261
+			Aliases: append(aliases, name),
258 262
 		})
259 263
 	}
260 264
 	return nets