Skip to content

Commit e42c3fe

Browse files
committed
also search image config file for platform
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 31f07cc commit e42c3fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/find_images.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ func FindImagesInOCITree(index v1.ImageIndex, matcher match.Matcher) ([]v1.Image
3333
for _, descriptor := range manifest.Manifests {
3434
switch {
3535
case descriptor.MediaType.IsImage():
36+
// If the platform is not part of the index manifest, attempt to
37+
// load it from the image config
38+
if descriptor.Platform == nil {
39+
img, err := index.Image(descriptor.Digest)
40+
if err != nil {
41+
return nil, fmt.Errorf("could not load image: %w", err)
42+
}
43+
44+
cfg, err := img.ConfigFile()
45+
if err != nil {
46+
return nil, fmt.Errorf("could not load image config: %w", err)
47+
}
48+
49+
descriptor.Platform = cfg.Platform()
50+
}
51+
3652
if matcher(descriptor) {
3753
img, err := index.Image(descriptor.Digest)
3854
if err != nil {

0 commit comments

Comments
 (0)