@@ -29,9 +29,6 @@ import (
29
29
"github.com/containerd/errdefs"
30
30
"github.com/containerd/log"
31
31
"github.com/containerd/platforms"
32
-
33
- // nolint:staticcheck
34
- "github.com/containerd/containerd/v2/core/remotes/docker/schema1"
35
32
"github.com/opencontainers/go-digest"
36
33
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
37
34
"golang.org/x/sync/semaphore"
@@ -41,7 +38,7 @@ import (
41
38
var fetchSingleflight = & singleflight.Group {}
42
39
43
40
// Ported from containerd project, copyright The containerd Authors.
44
- // github.com/containerd/containerd/blob/main/pull.go
41
+ // github.com/containerd/containerd/blob/main/client/ pull.go
45
42
func fetch (ctx context.Context , store content.Store , rCtx * client.RemoteContext , ref string , limit int ) (images.Image , error ) {
46
43
name , desc , err := rCtx .Resolver .Resolve (ctx , ref )
47
44
if err != nil {
@@ -61,66 +58,56 @@ func fetch(ctx context.Context, store content.Store, rCtx *client.RemoteContext,
61
58
limiter * semaphore.Weighted
62
59
)
63
60
64
- // nolint:staticcheck
65
- if desc .MediaType == images .MediaTypeDockerSchema1Manifest && rCtx .ConvertSchema1 {
66
- schema1Converter , err := schema1 .NewConverter (store , fetcher )
67
- if err != nil {
68
- return images.Image {}, fmt .Errorf ("failed to create schema1 converter: %w" , err )
69
- }
70
-
71
- handler = images .Handlers (append (rCtx .BaseHandlers , schema1Converter )... )
72
-
73
- isConvertible = true
61
+ if desc .MediaType == images .MediaTypeDockerSchema1Manifest {
62
+ return images.Image {}, fmt .Errorf ("%w: media type %q is no longer supported since containerd v2.1, please rebuild the image as %q or %q" ,
63
+ errdefs .ErrNotImplemented ,
64
+ images .MediaTypeDockerSchema1Manifest , images .MediaTypeDockerSchema2Manifest , ocispec .MediaTypeImageManifest )
65
+ }
74
66
75
- converterFunc = func (ctx context.Context , _ ocispec.Descriptor ) (ocispec.Descriptor , error ) {
76
- return schema1Converter .Convert (ctx )
77
- }
67
+ // Get all the children for a descriptor
68
+ childrenHandler := images .ChildrenHandler (store )
69
+ // Set any children labels for that content
70
+ childrenHandler = images .SetChildrenMappedLabels (store , childrenHandler , rCtx .ChildLabelMap )
71
+ if rCtx .AllMetadata {
72
+ // Filter manifests by platforms but allow to handle manifest
73
+ // and configuration for not-target platforms
74
+ childrenHandler = remotes .FilterManifestByPlatformHandler (childrenHandler , rCtx .PlatformMatcher )
78
75
} else {
79
- // Get all the children for a descriptor
80
- childrenHandler := images .ChildrenHandler (store )
81
- // Set any children labels for that content
82
- childrenHandler = images .SetChildrenMappedLabels (store , childrenHandler , rCtx .ChildLabelMap )
83
- if rCtx .AllMetadata {
84
- // Filter manifests by platforms but allow to handle manifest
85
- // and configuration for not-target platforms
86
- childrenHandler = remotes .FilterManifestByPlatformHandler (childrenHandler , rCtx .PlatformMatcher )
87
- } else {
88
- // Filter children by platforms if specified.
89
- childrenHandler = images .FilterPlatforms (childrenHandler , rCtx .PlatformMatcher )
90
- }
91
- // Sort and limit manifests if a finite number is needed
92
- if limit > 0 {
93
- childrenHandler = images .LimitManifests (childrenHandler , rCtx .PlatformMatcher , limit )
94
- }
76
+ // Filter children by platforms if specified.
77
+ childrenHandler = images .FilterPlatforms (childrenHandler , rCtx .PlatformMatcher )
78
+ }
79
+ // Sort and limit manifests if a finite number is needed
80
+ if limit > 0 {
81
+ childrenHandler = images .LimitManifests (childrenHandler , rCtx .PlatformMatcher , limit )
82
+ }
95
83
96
- // set isConvertible to true if there is application/octet-stream media type
97
- convertibleHandler := images .HandlerFunc (
98
- func (_ context.Context , desc ocispec.Descriptor ) ([]ocispec.Descriptor , error ) {
99
- if desc .MediaType == docker .LegacyConfigMediaType {
100
- isConvertible = true
101
- }
84
+ // set isConvertible to true if there is application/octet-stream media type
85
+ convertibleHandler := images .HandlerFunc (
86
+ func (_ context.Context , desc ocispec.Descriptor ) ([]ocispec.Descriptor , error ) {
87
+ if desc .MediaType == docker .LegacyConfigMediaType {
88
+ isConvertible = true
89
+ }
102
90
103
- return []ocispec.Descriptor {}, nil
104
- },
105
- )
91
+ return []ocispec.Descriptor {}, nil
92
+ },
93
+ )
106
94
107
- appendDistSrcLabelHandler , err := docker .AppendDistributionSourceLabel (store , ref )
108
- if err != nil {
109
- return images.Image {}, err
110
- }
95
+ appendDistSrcLabelHandler , err := docker .AppendDistributionSourceLabel (store , ref )
96
+ if err != nil {
97
+ return images.Image {}, err
98
+ }
111
99
112
- handlers := append (rCtx .BaseHandlers ,
113
- fetchHandler (store , fetcher ),
114
- convertibleHandler ,
115
- childrenHandler ,
116
- appendDistSrcLabelHandler ,
117
- )
100
+ handlers := append (rCtx .BaseHandlers ,
101
+ fetchHandler (store , fetcher ),
102
+ convertibleHandler ,
103
+ childrenHandler ,
104
+ appendDistSrcLabelHandler ,
105
+ )
118
106
119
- handler = images .Handlers (handlers ... )
107
+ handler = images .Handlers (handlers ... )
120
108
121
- converterFunc = func (ctx context.Context , desc ocispec.Descriptor ) (ocispec.Descriptor , error ) {
122
- return docker .ConvertManifest (ctx , store , desc )
123
- }
109
+ converterFunc = func (ctx context.Context , desc ocispec.Descriptor ) (ocispec.Descriptor , error ) {
110
+ return docker .ConvertManifest (ctx , store , desc )
124
111
}
125
112
126
113
if rCtx .HandlerWrapper != nil {
@@ -174,7 +161,7 @@ func fetchHandler(ingester content.Ingester, fetcher remotes.Fetcher) images.Han
174
161
}
175
162
176
163
// Ported from containerd project, copyright The containerd Authors.
177
- // github.com/containerd/containerd/blob/main/client.go
164
+ // github.com/containerd/containerd/blob/main/client/client .go
178
165
func push (ctx context.Context , store content.Store , pushCtx * client.RemoteContext , desc ocispec.Descriptor , ref string ) error {
179
166
if pushCtx .PlatformMatcher == nil {
180
167
if len (pushCtx .Platforms ) > 0 {
0 commit comments