Browse code

Implement ipamconfig.subnet and be more explicit about restart policy always.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2016/11/11 06:22:31
Showing 1 changed files
... ...
@@ -178,13 +178,19 @@ func convertNetworks(
178 178
 			Options: network.DriverOpts,
179 179
 		}
180 180
 
181
+		if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
182
+			createOpts.IPAM = &networktypes.IPAM{}
183
+		}
184
+
181 185
 		if network.Ipam.Driver != "" {
182
-			createOpts.IPAM = &networktypes.IPAM{
183
-				Driver: network.Ipam.Driver,
186
+			createOpts.IPAM.Driver = network.Ipam.Driver
187
+		}
188
+		for _, ipamConfig := range network.Ipam.Config {
189
+			config := networktypes.IPAMConfig{
190
+				Subnet: ipamConfig.Subnet,
184 191
 			}
192
+			createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
185 193
 		}
186
-		// TODO: IPAMConfig.Config
187
-
188 194
 		result[internalName] = createOpts
189 195
 	}
190 196
 
... ...
@@ -523,8 +529,12 @@ func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*
523 523
 		}
524 524
 		// TODO: is this an accurate convertion?
525 525
 		switch {
526
-		case policy.IsNone(), policy.IsAlways(), policy.IsUnlessStopped():
526
+		case policy.IsNone():
527 527
 			return nil, nil
528
+		case policy.IsAlways(), policy.IsUnlessStopped():
529
+			return &swarm.RestartPolicy{
530
+				Condition: swarm.RestartPolicyConditionAny,
531
+			}, nil
528 532
 		case policy.IsOnFailure():
529 533
 			attempts := uint64(policy.MaximumRetryCount)
530 534
 			return &swarm.RestartPolicy{