Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
| ... | ... |
@@ -39,7 +39,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, |
| 39 | 39 |
service.TaskTemplate.ContainerSpec.Image = img |
| 40 | 40 |
} |
| 41 | 41 |
// add platforms that are compatible with the service |
| 42 |
- service.TaskTemplate.Placement = updateServicePlatforms(service.TaskTemplate.Placement, distributionInspect) |
|
| 42 |
+ service.TaskTemplate.Placement = setServicePlatforms(service.TaskTemplate.Placement, distributionInspect) |
|
| 43 | 43 |
} |
| 44 | 44 |
} |
| 45 | 45 |
var response types.ServiceCreateResponse |
| ... | ... |
@@ -86,13 +86,15 @@ func imageWithTagString(image string) string {
|
| 86 | 86 |
return "" |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 |
-// updateServicePlatforms updates the Platforms in swarm.Placement to list |
|
| 90 |
-// all compatible platforms for the service, as found in distributionInspect |
|
| 91 |
-// and returns a pointer to the new or updated swarm.Placement struct |
|
| 92 |
-func updateServicePlatforms(placement *swarm.Placement, distributionInspect registrytypes.DistributionInspect) *swarm.Placement {
|
|
| 89 |
+// setServicePlatforms sets Platforms in swarm.Placement to list all |
|
| 90 |
+// compatible platforms for the service, as found in distributionInspect |
|
| 91 |
+// and returns a pointer to the new or updated swarm.Placement struct. |
|
| 92 |
+func setServicePlatforms(placement *swarm.Placement, distributionInspect registrytypes.DistributionInspect) *swarm.Placement {
|
|
| 93 | 93 |
if placement == nil {
|
| 94 | 94 |
placement = &swarm.Placement{}
|
| 95 | 95 |
} |
| 96 |
+ // reset any existing listed platforms |
|
| 97 |
+ placement.Platforms = []swarm.Platform{}
|
|
| 96 | 98 |
for _, p := range distributionInspect.Platforms {
|
| 97 | 99 |
placement.Platforms = append(placement.Platforms, swarm.Platform{
|
| 98 | 100 |
Architecture: p.Architecture, |
| ... | ... |
@@ -51,7 +51,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version |
| 51 | 51 |
service.TaskTemplate.ContainerSpec.Image = img |
| 52 | 52 |
} |
| 53 | 53 |
// add platforms that are compatible with the service |
| 54 |
- service.TaskTemplate.Placement = updateServicePlatforms(service.TaskTemplate.Placement, distributionInspect) |
|
| 54 |
+ service.TaskTemplate.Placement = setServicePlatforms(service.TaskTemplate.Placement, distributionInspect) |
|
| 55 | 55 |
} |
| 56 | 56 |
} |
| 57 | 57 |
|