(ctx context.Context, project *types.Project)
| 190 | } |
| 191 | |
| 192 | func (s *composeService) getLocalImagesDigests(ctx context.Context, project *types.Project) (map[string]api.ImageSummary, error) { |
| 193 | imageNames := utils.Set[string]{} |
| 194 | for _, s := range project.Services { |
| 195 | imageNames.Add(api.GetImageNameOrDefault(s, project.Name)) |
| 196 | for _, volume := range s.Volumes { |
| 197 | if volume.Type == types.VolumeTypeImage { |
| 198 | imageNames.Add(volume.Source) |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | imgs, err := s.getImageSummaries(ctx, imageNames.Elements()) |
| 203 | if err != nil { |
| 204 | return nil, err |
| 205 | } |
| 206 | |
| 207 | for i, service := range project.Services { |
| 208 | imgName := api.GetImageNameOrDefault(service, project.Name) |
| 209 | img, ok := imgs[imgName] |
| 210 | if !ok { |
| 211 | continue |
| 212 | } |
| 213 | if service.Platform != "" { |
| 214 | platform, err := platforms.Parse(service.Platform) |
| 215 | if err != nil { |
| 216 | return nil, err |
| 217 | } |
| 218 | inspect, err := s.apiClient().ImageInspect(ctx, img.ID) |
| 219 | if err != nil { |
| 220 | return nil, err |
| 221 | } |
| 222 | actual := specs.Platform{ |
| 223 | Architecture: inspect.Architecture, |
| 224 | OS: inspect.Os, |
| 225 | Variant: inspect.Variant, |
| 226 | } |
| 227 | if !platforms.NewMatcher(platform).Match(actual) { |
| 228 | logrus.Debugf("local image %s doesn't match expected platform %s", service.Image, service.Platform) |
| 229 | // there is a local image, but it's for the wrong platform, so |
| 230 | // pretend it doesn't exist so that we can pull/build an image |
| 231 | // for the correct platform instead |
| 232 | delete(imgs, imgName) |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | project.Services[i].CustomLabels.Add(api.ImageDigestLabel, img.ID) |
| 237 | |
| 238 | } |
| 239 | |
| 240 | return imgs, nil |
| 241 | } |
| 242 | |
| 243 | // resolveAndMergeBuildArgs returns the final set of build arguments to use for the service image build. |
| 244 | // |
no test coverage detected