@@ -39,7 +39,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec,
3939 service .TaskTemplate .ContainerSpec .Image = img
4040 }
4141 // 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 )
4343 }
4444 }
4545 var response types.ServiceCreateResponse
@@ -86,13 +86,15 @@ func imageWithTagString(image string) string {
8686 return ""
8787}
8888
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 {
9393 if placement == nil {
9494 placement = & swarm.Placement {}
9595 }
96+ // reset any existing listed platforms
97+ placement .Platforms = []swarm.Platform {}
9698 for _ , p := range distributionInspect .Platforms {
9799 placement .Platforms = append (placement .Platforms , swarm.Platform {
98100 Architecture : p .Architecture ,
0 commit comments