Merge pull request #7376 from tianon/oci-platform

This commit is contained in:
Samuel Karp 2023-05-30 18:14:31 -07:00 committed by GitHub
commit 8b66a752c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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