@@ -25,6 +25,7 @@ import (
25
25
"oras.land/oras-go/v2/content"
26
26
"oras.land/oras-go/v2/errdef"
27
27
"oras.land/oras-go/v2/internal/docker"
28
+ "oras.land/oras-go/v2/internal/manifestutil"
28
29
)
29
30
30
31
// Match checks whether the current platform matches the target platform.
@@ -35,7 +36,7 @@ import (
35
36
// array of the current platform.
36
37
//
37
38
// Note: Variant, OSVersion and OSFeatures are optional fields, will skip
38
- // the comparison if the target platform does not provide specfic value.
39
+ // the comparison if the target platform does not provide specific value.
39
40
func Match (got * ocispec.Platform , want * ocispec.Platform ) bool {
40
41
if got .Architecture != want .Architecture || got .OS != want .OS {
41
42
return false
@@ -77,7 +78,7 @@ func isSubset(a, b []string) bool {
77
78
func SelectManifest (ctx context.Context , src content.ReadOnlyStorage , root ocispec.Descriptor , p * ocispec.Platform ) (ocispec.Descriptor , error ) {
78
79
switch root .MediaType {
79
80
case docker .MediaTypeManifestList , ocispec .MediaTypeImageIndex :
80
- manifests , err := content . Successors (ctx , src , root )
81
+ manifests , err := manifestutil . Manifests (ctx , src , root )
81
82
if err != nil {
82
83
return ocispec.Descriptor {}, err
83
84
}
@@ -90,7 +91,8 @@ func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocisp
90
91
}
91
92
return ocispec.Descriptor {}, fmt .Errorf ("%s: %w: no matching manifest was found in the manifest list" , root .Digest , errdef .ErrNotFound )
92
93
case docker .MediaTypeManifest , ocispec .MediaTypeImageManifest :
93
- descs , err := content .Successors (ctx , src , root )
94
+ // config will be non-nil for docker manifest and OCI image manifest
95
+ config , err := manifestutil .Config (ctx , src , root )
94
96
if err != nil {
95
97
return ocispec.Descriptor {}, err
96
98
}
@@ -99,8 +101,7 @@ func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocisp
99
101
if root .MediaType == ocispec .MediaTypeImageManifest {
100
102
configMediaType = ocispec .MediaTypeImageConfig
101
103
}
102
-
103
- cfgPlatform , err := getPlatformFromConfig (ctx , src , descs [0 ], configMediaType )
104
+ cfgPlatform , err := getPlatformFromConfig (ctx , src , * config , configMediaType )
104
105
if err != nil {
105
106
return ocispec.Descriptor {}, err
106
107
}
0 commit comments