diff options
author | Tonis Tiigi <tonistiigi@gmail.com> | 2018-06-27 15:21:16 -0700 |
---|---|---|
committer | Tonis Tiigi <tonistiigi@gmail.com> | 2018-06-27 15:33:07 -0700 |
commit | 951faaed664dd51d2aacfdb782534f4c46bd9e23 (patch) | |
tree | 5b4e33ab349aaf581a3d1f3a5bffa0995e2296e0 /distribution | |
parent | f0997716651b6e6c2b07e3d514bf8452114a1433 (diff) | |
download | docker-951faaed664dd51d2aacfdb782534f4c46bd9e23.tar.gz |
distribution: remove custom matcher code
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Diffstat (limited to 'distribution')
-rw-r--r-- | distribution/pull_v2_unix.go | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/distribution/pull_v2_unix.go b/distribution/pull_v2_unix.go index 8d2c311f76..adbaf41451 100644 --- a/distribution/pull_v2_unix.go +++ b/distribution/pull_v2_unix.go @@ -18,10 +18,11 @@ func (ld *v2LayerDescriptor) open(ctx context.Context) (distribution.ReadSeekClo } func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platform) []manifestlist.ManifestDescriptor { - p = withDefault(p) + p = platforms.Normalize(withDefault(p)) + m := platforms.NewMatcher(p) var matches []manifestlist.ManifestDescriptor for _, desc := range manifests { - if compareNormalized(toOCIPlatform(desc.Platform), p) { + if m.Match(toOCIPlatform(desc.Platform)) { matches = append(matches, desc) logrus.Debugf("found match for %s with media type %s, digest %s", platforms.Format(p), desc.MediaType, desc.Digest.String()) } @@ -29,7 +30,7 @@ func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platfo // deprecated: backwards compatibility with older versions that didn't compare variant if len(matches) == 0 && p.Architecture == "arm" { - p = normalize(p) + p = platforms.Normalize(p) for _, desc := range manifests { if desc.Platform.OS == p.OS && desc.Platform.Architecture == p.Architecture { matches = append(matches, desc) @@ -57,26 +58,3 @@ func withDefault(p specs.Platform) specs.Platform { } return p } - -func compareNormalized(p1, p2 specs.Platform) bool { - // remove after https://github.com/containerd/containerd/pull/2414 - return p1.OS == p2.OS && - p1.Architecture == p2.Architecture && - p1.Variant == p2.Variant -} - -func normalize(p specs.Platform) specs.Platform { - p = platforms.Normalize(p) - // remove after https://github.com/containerd/containerd/pull/2414 - if p.Architecture == "arm" { - if p.Variant == "" { - p.Variant = "v7" - } - } - if p.Architecture == "arm64" { - if p.Variant == "" { - p.Variant = "v8" - } - } - return p -} |