diff --git a/image.go b/image.go index 6d0a67617..d3cfdba6f 100644 --- a/image.go +++ b/image.go @@ -472,11 +472,13 @@ func (i *image) getManifestPlatform(ctx context.Context, manifest ocispec.Manife return ocispec.Platform{}, err } - var image ocispec.Image - if err := json.Unmarshal(p, &image); err != nil { + // Technically, this should be ocispec.Image, but we only need the + // ocispec.Platform that is embedded in the image struct. + var imagePlatform ocispec.Platform + if err := json.Unmarshal(p, &imagePlatform); err != nil { return ocispec.Platform{}, err } - return platforms.Normalize(ocispec.Platform{OS: image.OS, Architecture: image.Architecture}), nil + return platforms.Normalize(imagePlatform), nil } func (i *image) checkSnapshotterSupport(ctx context.Context, snapshotterName string, manifest ocispec.Manifest) error { diff --git a/images/image.go b/images/image.go index 2d2e36a9a..f3c8d4de3 100644 --- a/images/image.go +++ b/images/image.go @@ -174,12 +174,14 @@ func Manifest(ctx context.Context, provider content.Provider, image ocispec.Desc return nil, err } - var image ocispec.Image - if err := json.Unmarshal(p, &image); err != nil { + // Technically, this should be ocispec.Image, but we only need the + // ocispec.Platform that is embedded in the image struct. + var imagePlatform ocispec.Platform + if err := json.Unmarshal(p, &imagePlatform); err != nil { return nil, err } - if !platform.Match(platforms.Normalize(ocispec.Platform{OS: image.OS, Architecture: image.Architecture})) { + if !platform.Match(platforms.Normalize(imagePlatform)) { return nil, nil } @@ -279,13 +281,14 @@ func Platforms(ctx context.Context, provider content.Provider, image ocispec.Des return nil, err } - var image ocispec.Image - if err := json.Unmarshal(p, &image); err != nil { + // Technically, this should be ocispec.Image, but we only need the + // ocispec.Platform that is embedded in the image struct. + var imagePlatform ocispec.Platform + if err := json.Unmarshal(p, &imagePlatform); err != nil { return nil, err } - platformSpecs = append(platformSpecs, - platforms.Normalize(ocispec.Platform{OS: image.OS, Architecture: image.Architecture})) + platformSpecs = append(platformSpecs, platforms.Normalize(imagePlatform)) } return nil, nil }), ChildrenHandler(provider)), image) diff --git a/pkg/unpack/unpacker.go b/pkg/unpack/unpacker.go index b160da652..43c963f90 100644 --- a/pkg/unpack/unpacker.go +++ b/pkg/unpack/unpacker.go @@ -253,7 +253,7 @@ func (u *Unpacker) unpack( // TODO: Support multiple unpacks rather than just first match var unpack *Platform - imgPlatform := platforms.Normalize(ocispec.Platform{OS: i.OS, Architecture: i.Architecture}) + imgPlatform := platforms.Normalize(i.Platform) for _, up := range u.platforms { if up.Platform.Match(imgPlatform) { unpack = up