瀏覽代碼

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 158388ef8d66723ec1f8ee4770d7488948234d16)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
Vincent Demeester 8 年之前
父節點
當前提交
05eb544ae2
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      cli/command/stack/deploy.go

+ 5 - 1
cli/command/stack/deploy.go

@@ -252,9 +252,13 @@ func convertServiceNetworks(
 
 	nets := []swarm.NetworkAttachmentConfig{}
 	for networkName, network := range networks {
+		var aliases []string
+		if network != nil {
+			aliases = network.Aliases
+		}
 		nets = append(nets, swarm.NetworkAttachmentConfig{
 			Target:  namespace.scope(networkName),
-			Aliases: append(network.Aliases, name),
+			Aliases: append(aliases, name),
 		})
 	}
 	return nets