@@ -27,7 +27,6 @@ import (
2727 "github.com/containerd/containerd/v2/core/images"
2828 "github.com/containerd/containerd/v2/core/remotes"
2929 "github.com/containerd/containerd/v2/core/remotes/docker"
30- "github.com/containerd/containerd/v2/core/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
3130 "github.com/containerd/containerd/v2/pkg/tracing"
3231 "github.com/containerd/containerd/v2/pkg/unpack"
3332 "github.com/containerd/errdefs"
@@ -164,7 +163,7 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (_ Ima
164163
165164 if unpacker != nil && ur .Unpacks == 0 {
166165 // Unpack was tried previously but nothing was unpacked
167- // This is at least required for schema 1 image.
166+ // This was at least required for schema 1 image.
168167 if err := i .Unpack (ctx , pullCtx .Snapshotter , pullCtx .UnpackOpts ... ); err != nil {
169168 return nil , fmt .Errorf ("failed to unpack image on snapshotter %s: %w" , pullCtx .Snapshotter , err )
170169 }
@@ -190,70 +189,60 @@ func (c *Client) fetch(ctx context.Context, rCtx *RemoteContext, ref string, lim
190189 var (
191190 handler images.Handler
192191
193- isConvertible bool
194- originalSchema1Digest string
195- converterFunc func (context.Context , ocispec.Descriptor ) (ocispec.Descriptor , error )
196- limiter * semaphore.Weighted
192+ isConvertible bool
193+ converterFunc func (context.Context , ocispec.Descriptor ) (ocispec.Descriptor , error )
194+ limiter * semaphore.Weighted
197195 )
198196
199- if desc .MediaType == images .MediaTypeDockerSchema1Manifest && rCtx .ConvertSchema1 {
200- schema1Converter := schema1 .NewConverter (store , fetcher )
201-
202- handler = images .Handlers (append (rCtx .BaseHandlers , schema1Converter )... )
203-
204- isConvertible = true
205-
206- converterFunc = func (ctx context.Context , _ ocispec.Descriptor ) (ocispec.Descriptor , error ) {
207- return schema1Converter .Convert (ctx )
208- }
209-
210- originalSchema1Digest = desc .Digest .String ()
197+ if desc .MediaType == images .MediaTypeDockerSchema1Manifest {
198+ return images.Image {}, fmt .Errorf ("%w: media type %q is no longer supported since containerd v2.0, please rebuild the image as %q or %q" ,
199+ errdefs .ErrNotImplemented ,
200+ images .MediaTypeDockerSchema1Manifest , images .MediaTypeDockerSchema2Manifest , ocispec .MediaTypeImageManifest )
201+ }
202+ // Get all the children for a descriptor
203+ childrenHandler := images .ChildrenHandler (store )
204+ // Set any children labels for that content
205+ childrenHandler = images .SetChildrenMappedLabels (store , childrenHandler , rCtx .ChildLabelMap )
206+ if rCtx .AllMetadata {
207+ // Filter manifests by platforms but allow to handle manifest
208+ // and configuration for not-target platforms
209+ childrenHandler = remotes .FilterManifestByPlatformHandler (childrenHandler , rCtx .PlatformMatcher )
211210 } else {
212- // Get all the children for a descriptor
213- childrenHandler := images .ChildrenHandler (store )
214- // Set any children labels for that content
215- childrenHandler = images .SetChildrenMappedLabels (store , childrenHandler , rCtx .ChildLabelMap )
216- if rCtx .AllMetadata {
217- // Filter manifests by platforms but allow to handle manifest
218- // and configuration for not-target platforms
219- childrenHandler = remotes .FilterManifestByPlatformHandler (childrenHandler , rCtx .PlatformMatcher )
220- } else {
221- // Filter children by platforms if specified.
222- childrenHandler = images .FilterPlatforms (childrenHandler , rCtx .PlatformMatcher )
223- }
224- // Sort and limit manifests if a finite number is needed
225- if limit > 0 {
226- childrenHandler = images .LimitManifests (childrenHandler , rCtx .PlatformMatcher , limit )
227- }
211+ // Filter children by platforms if specified.
212+ childrenHandler = images .FilterPlatforms (childrenHandler , rCtx .PlatformMatcher )
213+ }
214+ // Sort and limit manifests if a finite number is needed
215+ if limit > 0 {
216+ childrenHandler = images .LimitManifests (childrenHandler , rCtx .PlatformMatcher , limit )
217+ }
228218
229- // set isConvertible to true if there is application/octet-stream media type
230- convertibleHandler := images .HandlerFunc (
231- func (_ context.Context , desc ocispec.Descriptor ) ([]ocispec.Descriptor , error ) {
232- if desc .MediaType == docker .LegacyConfigMediaType {
233- isConvertible = true
234- }
219+ // set isConvertible to true if there is application/octet-stream media type
220+ convertibleHandler := images .HandlerFunc (
221+ func (_ context.Context , desc ocispec.Descriptor ) ([]ocispec.Descriptor , error ) {
222+ if desc .MediaType == docker .LegacyConfigMediaType {
223+ isConvertible = true
224+ }
235225
236- return []ocispec.Descriptor {}, nil
237- },
238- )
226+ return []ocispec.Descriptor {}, nil
227+ },
228+ )
239229
240- appendDistSrcLabelHandler , err := docker .AppendDistributionSourceLabel (store , ref )
241- if err != nil {
242- return images.Image {}, err
243- }
230+ appendDistSrcLabelHandler , err := docker .AppendDistributionSourceLabel (store , ref )
231+ if err != nil {
232+ return images.Image {}, err
233+ }
244234
245- handlers := append (rCtx .BaseHandlers ,
246- remotes .FetchHandler (store , fetcher ),
247- convertibleHandler ,
248- childrenHandler ,
249- appendDistSrcLabelHandler ,
250- )
235+ handlers := append (rCtx .BaseHandlers ,
236+ remotes .FetchHandler (store , fetcher ),
237+ convertibleHandler ,
238+ childrenHandler ,
239+ appendDistSrcLabelHandler ,
240+ )
251241
252- handler = images .Handlers (handlers ... )
242+ handler = images .Handlers (handlers ... )
253243
254- converterFunc = func (ctx context.Context , desc ocispec.Descriptor ) (ocispec.Descriptor , error ) {
255- return docker .ConvertManifest (ctx , store , desc )
256- }
244+ converterFunc = func (ctx context.Context , desc ocispec.Descriptor ) (ocispec.Descriptor , error ) {
245+ return docker .ConvertManifest (ctx , store , desc )
257246 }
258247
259248 if rCtx .HandlerWrapper != nil {
@@ -274,13 +263,6 @@ func (c *Client) fetch(ctx context.Context, rCtx *RemoteContext, ref string, lim
274263 }
275264 }
276265
277- if originalSchema1Digest != "" {
278- if rCtx .Labels == nil {
279- rCtx .Labels = make (map [string ]string )
280- }
281- rCtx .Labels [images .ConvertedDockerSchema1LabelKey ] = originalSchema1Digest
282- }
283-
284266 return images.Image {
285267 Name : name ,
286268 Target : desc ,
0 commit comments