|
5 | 5 | "strings"
|
6 | 6 |
|
7 | 7 | composetypes "github.com/compose-spec/compose-go/v2/types"
|
8 |
| - "github.com/docker/docker/api/types" |
9 | 8 | networktypes "github.com/docker/docker/api/types/network"
|
10 | 9 | "github.com/docker/docker/api/types/swarm"
|
11 | 10 | )
|
@@ -52,45 +51,45 @@ func AddStackLabel(namespace Namespace, labels map[string]string) map[string]str
|
52 | 51 | type networkMap map[string]composetypes.NetworkConfig
|
53 | 52 |
|
54 | 53 | // Networks from the compose-file type to the engine API type
|
55 |
| -func Networks(namespace Namespace, networks composetypes.Networks, servicesNetworks map[string]struct{}) (map[string]types.NetworkCreate, []string) { |
| 54 | +func Networks(namespace Namespace, networks composetypes.Networks, servicesNetworks map[string]struct{}) (map[string]networktypes.CreateOptions, []string) { |
56 | 55 | if networks == nil {
|
57 | 56 | networks = make(map[string]composetypes.NetworkConfig)
|
58 | 57 | }
|
59 | 58 |
|
60 | 59 | externalNetworks := []string{}
|
61 |
| - result := make(map[string]network.CreateOptions) |
| 60 | + result := make(map[string]networktypes.CreateOptions) |
62 | 61 | for internalName := range servicesNetworks {
|
63 | 62 | network := networks[internalName]
|
64 | 63 | if network.External {
|
65 | 64 | externalNetworks = append(externalNetworks, network.Name)
|
66 | 65 | continue
|
67 | 66 | }
|
68 | 67 |
|
69 |
| - createOpts := network.CreateOptions{ |
70 |
| - Labels: AddStackLabel(namespace, nw.Labels), |
71 |
| - Driver: nw.Driver, |
72 |
| - Options: nw.DriverOpts, |
73 |
| - Internal: nw.Internal, |
74 |
| - Attachable: nw.Attachable, |
| 68 | + createOpts := networktypes.CreateOptions{ |
| 69 | + Labels: AddStackLabel(namespace, network.Labels), |
| 70 | + Driver: network.Driver, |
| 71 | + Options: network.DriverOpts, |
| 72 | + Internal: network.Internal, |
| 73 | + Attachable: network.Attachable, |
75 | 74 | }
|
76 | 75 |
|
77 |
| - if nw.Ipam.Driver != "" || len(nw.Ipam.Config) > 0 { |
78 |
| - createOpts.IPAM = &network.IPAM{} |
| 76 | + if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 { |
| 77 | + createOpts.IPAM = &networktypes.IPAM{} |
79 | 78 | }
|
80 | 79 |
|
81 |
| - if nw.Ipam.Driver != "" { |
82 |
| - createOpts.IPAM.Driver = nw.Ipam.Driver |
| 80 | + if network.Ipam.Driver != "" { |
| 81 | + createOpts.IPAM.Driver = network.Ipam.Driver |
83 | 82 | }
|
84 |
| - for _, ipamConfig := range nw.Ipam.Config { |
85 |
| - config := network.IPAMConfig{ |
| 83 | + for _, ipamConfig := range network.Ipam.Config { |
| 84 | + config := networktypes.IPAMConfig{ |
86 | 85 | Subnet: ipamConfig.Subnet,
|
87 | 86 | }
|
88 | 87 | createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
|
89 | 88 | }
|
90 | 89 |
|
91 | 90 | networkName := namespace.Scope(internalName)
|
92 |
| - if nw.Name != "" { |
93 |
| - networkName = nw.Name |
| 91 | + if network.Name != "" { |
| 92 | + networkName = network.Name |
94 | 93 | }
|
95 | 94 | result[networkName] = createOpts
|
96 | 95 | }
|
|
0 commit comments