github.com/rawahars/moby@v24.0.4+incompatible/pkg/platforms/platforms.go (about) 1 package platforms 2 3 import ( 4 cplatforms "github.com/containerd/containerd/platforms" 5 ocispec "github.com/opencontainers/image-spec/specs-go/v1" 6 ) 7 8 type allPlatformsWithPreferenceMatcher struct { 9 preferred cplatforms.MatchComparer 10 } 11 12 // AllPlatformsWithPreference will return a platform matcher that matches all 13 // platforms but will order platforms matching the preferred matcher first. 14 func AllPlatformsWithPreference(preferred cplatforms.MatchComparer) cplatforms.MatchComparer { 15 return allPlatformsWithPreferenceMatcher{ 16 preferred: preferred, 17 } 18 } 19 20 func (c allPlatformsWithPreferenceMatcher) Match(_ ocispec.Platform) bool { 21 return true 22 } 23 24 func (c allPlatformsWithPreferenceMatcher) Less(p1, p2 ocispec.Platform) bool { 25 return c.preferred.Less(p1, p2) 26 }