694df3ff |
// +build !windows
|
4f0d95fa |
package distribution // import "github.com/docker/docker/distribution" |
694df3ff |
import ( |
07ffa1ce |
"context" |
38aef56e |
|
337ba71f |
"github.com/containerd/containerd/platforms" |
05bd0435 |
"github.com/docker/distribution" |
38aef56e |
"github.com/docker/distribution/manifest/manifestlist" |
337ba71f |
specs "github.com/opencontainers/image-spec/specs-go/v1" |
38aef56e |
"github.com/sirupsen/logrus" |
694df3ff |
)
|
05bd0435 |
func (ld *v2LayerDescriptor) open(ctx context.Context) (distribution.ReadSeekCloser, error) {
blobs := ld.repo.Blobs(ctx)
return blobs.Open(ctx, ld.digest)
} |
38aef56e |
|
337ba71f |
func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platform) []manifestlist.ManifestDescriptor { |
951faaed |
p = platforms.Normalize(withDefault(p))
m := platforms.NewMatcher(p) |
38aef56e |
var matches []manifestlist.ManifestDescriptor |
337ba71f |
for _, desc := range manifests { |
951faaed |
if m.Match(toOCIPlatform(desc.Platform)) { |
337ba71f |
matches = append(matches, desc)
logrus.Debugf("found match for %s with media type %s, digest %s", platforms.Format(p), desc.MediaType, desc.Digest.String())
}
} |
38aef56e |
|
337ba71f |
// deprecated: backwards compatibility with older versions that didn't compare variant
if len(matches) == 0 && p.Architecture == "arm" { |
951faaed |
p = platforms.Normalize(p) |
337ba71f |
for _, desc := range manifests {
if desc.Platform.OS == p.OS && desc.Platform.Architecture == p.Architecture {
matches = append(matches, desc)
logrus.Debugf("found deprecated partial match for %s with media type %s, digest %s", platforms.Format(p), desc.MediaType, desc.Digest.String())
} |
38aef56e |
}
} |
337ba71f |
|
38aef56e |
return matches
} |
83908836 |
// checkImageCompatibility is a Windows-specific function. No-op on Linux
func checkImageCompatibility(imageOS, imageOSVersion string) error {
return nil
} |
337ba71f |
func withDefault(p specs.Platform) specs.Platform {
def := platforms.DefaultSpec()
if p.OS == "" {
p.OS = def.OS
}
if p.Architecture == "" {
p.Architecture = def.Architecture
p.Variant = def.Variant
}
return p
} |
4b9db209 |
func formatPlatform(platform specs.Platform) string {
if platform.OS == "" {
platform = platforms.DefaultSpec()
}
return platforms.Format(platform)
} |