distribution: use correct platform matcher for containerd
This uses the correct comparison with compatibility checks for variants. The deprecated arm variant matcher is left as is. Although it is not needed for valid cases it is not fully compatible as also matches some invalid combinations, so should be removed separately. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
88e1fec490
commit
fcc42d5682
1 changed files with 6 additions and 1 deletions
|
@ -5,6 +5,7 @@ package distribution // import "github.com/docker/docker/distribution"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/docker/distribution"
|
||||
|
@ -20,7 +21,7 @@ func (ld *v2LayerDescriptor) open(ctx context.Context) (distribution.ReadSeekClo
|
|||
|
||||
func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platform) []manifestlist.ManifestDescriptor {
|
||||
p = platforms.Normalize(withDefault(p))
|
||||
m := platforms.NewMatcher(p)
|
||||
m := platforms.Only(p)
|
||||
var matches []manifestlist.ManifestDescriptor
|
||||
for _, desc := range manifests {
|
||||
if m.Match(toOCIPlatform(desc.Platform)) {
|
||||
|
@ -29,6 +30,10 @@ func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platfo
|
|||
}
|
||||
}
|
||||
|
||||
sort.SliceStable(matches, func(i, j int) bool {
|
||||
return m.Less(toOCIPlatform(matches[i].Platform), toOCIPlatform(matches[j].Platform))
|
||||
})
|
||||
|
||||
// deprecated: backwards compatibility with older versions that didn't compare variant
|
||||
if len(matches) == 0 && p.Architecture == "arm" {
|
||||
p = platforms.Normalize(p)
|
||||
|
|
Loading…
Add table
Reference in a new issue