8
8
"github.com/containerd/containerd/images"
9
9
"github.com/containerd/containerd/platforms"
10
10
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
11
+ "github.com/pkg/errors"
11
12
)
12
13
13
14
type ImageInfo struct {
@@ -66,6 +67,15 @@ func ReadImages(ctx context.Context, p content.Provider, desc ocispecs.Descripto
66
67
if err := json .Unmarshal (dt , & idx .Index ); err != nil {
67
68
return nil , err
68
69
}
70
+ if ! images .IsIndexType (idx .Index .MediaType ) {
71
+ img , err := ReadImage (ctx , p , desc )
72
+ if err != nil {
73
+ return nil , err
74
+ }
75
+ img .descPlatform = platforms .Format (img .Img .Platform )
76
+ idx .Images = append (idx .Images , img )
77
+ return idx , nil
78
+ }
69
79
70
80
for _ , m := range idx .Index .Manifests {
71
81
img , err := ReadImage (ctx , p , m )
@@ -88,6 +98,9 @@ func ReadImage(ctx context.Context, p content.Provider, desc ocispecs.Descriptor
88
98
if err := json .Unmarshal (dt , & ii .Manifest ); err != nil {
89
99
return nil , err
90
100
}
101
+ if ! images .IsManifestType (ii .Manifest .MediaType ) {
102
+ return nil , errors .Errorf ("invalid manifest type %s" , ii .Manifest .MediaType )
103
+ }
91
104
92
105
dt , err = content .ReadBlob (ctx , p , ii .Manifest .Config )
93
106
if err != nil {
0 commit comments