Skip to content

Commit dfd1227

Browse files
committed
Implement ipamconfig.subnet and be more explicit about restart policy always.
Signed-off-by: Daniel Nephin <[email protected]>
1 parent ef90081 commit dfd1227

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

cli/command/stack/deploy.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,19 @@ func convertNetworks(
178178
Options: network.DriverOpts,
179179
}
180180

181+
if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
182+
createOpts.IPAM = &networktypes.IPAM{}
183+
}
184+
181185
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,
184191
}
192+
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
185193
}
186-
// TODO: IPAMConfig.Config
187-
188194
result[internalName] = createOpts
189195
}
190196

@@ -523,8 +529,12 @@ func convertRestartPolicy(restart string, source *composetypes.RestartPolicy) (*
523529
}
524530
// TODO: is this an accurate convertion?
525531
switch {
526-
case policy.IsNone(), policy.IsAlways(), policy.IsUnlessStopped():
532+
case policy.IsNone():
527533
return nil, nil
534+
case policy.IsAlways(), policy.IsUnlessStopped():
535+
return &swarm.RestartPolicy{
536+
Condition: swarm.RestartPolicyConditionAny,
537+
}, nil
528538
case policy.IsOnFailure():
529539
attempts := uint64(policy.MaximumRetryCount)
530540
return &swarm.RestartPolicy{

0 commit comments

Comments
 (0)