moby/daemon/containerd/platform_matchers.go
Sebastiaan van Stijn 94b4765363
pkg/platforms: internalize in daemon/containerd
This matcher was only used internally in the containerd implementation of
the image store. Un-export it, and make it a local utility in that package
to prevent external use.

This package was introduced in 1616a09b61
(v24.0), and there are no known external consumers of this package, so there
should be no need to deprecate / alias the old location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-20 22:28:56 +01:00

26 lines
743 B
Go

package containerd
import (
"github.com/containerd/containerd/platforms"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
type allPlatformsWithPreferenceMatcher struct {
preferred platforms.MatchComparer
}
// matchAllWithPreference will return a platform matcher that matches all
// platforms but will order platforms matching the preferred matcher first.
func matchAllWithPreference(preferred platforms.MatchComparer) platforms.MatchComparer {
return allPlatformsWithPreferenceMatcher{
preferred: preferred,
}
}
func (c allPlatformsWithPreferenceMatcher) Match(_ ocispec.Platform) bool {
return true
}
func (c allPlatformsWithPreferenceMatcher) Less(p1, p2 ocispec.Platform) bool {
return c.preferred.Less(p1, p2)
}