MCPcopy Create free account
hub / github.com/containerd/nerdctl / PushImageWithTransfer

Function PushImageWithTransfer

pkg/imgutil/transfer.go:184–222  ·  view source on GitHub ↗
(ctx context.Context, client *containerd.Client, parsedReference *referenceutil.ImageReference, pushRef, rawRef string, options types.ImagePushOptions)

Source from the content-addressed store, hash-verified

182}
183
184func PushImageWithTransfer(ctx context.Context, client *containerd.Client, parsedReference *referenceutil.ImageReference, pushRef, rawRef string, options types.ImagePushOptions) error {
185 source, err := preparePushStore(pushRef, options)
186 if err != nil {
187 return err
188 }
189
190 progressWriter := io.Discard
191 if options.Stdout != nil {
192 progressWriter = options.Stdout
193 }
194
195 pusher, cleanup, err := createOCIRegistry(ctx, parsedReference, options.GOptions, false)
196 if err != nil {
197 return err
198 }
199 defer cleanup()
200
201 transferErr := doTransfer(ctx, client, source, pusher, options.Quiet, progressWriter)
202
203 if transferErr != nil && (errors.Is(transferErr, http.ErrSchemeMismatch) || errutil.IsErrConnectionRefused(transferErr) || errutil.IsErrHTTPResponseToHTTPSClient(transferErr) || errutil.IsErrTLSHandshakeFailure(transferErr)) {
204 if options.GOptions.InsecureRegistry {
205 log.G(ctx).WithError(transferErr).Warnf("server %q does not seem to support HTTPS, falling back to plain HTTP", parsedReference.Domain)
206 pusher, cleanup2, err := createOCIRegistry(ctx, parsedReference, options.GOptions, true)
207 if err != nil {
208 return err
209 }
210 defer cleanup2()
211 transferErr = doTransfer(ctx, client, source, pusher, options.Quiet, progressWriter)
212 }
213 }
214
215 if transferErr != nil {
216 log.G(ctx).WithError(transferErr).Errorf("server %q does not seem to support HTTPS", parsedReference.Domain)
217 log.G(ctx).Info("Hint: you may want to try --insecure-registry to allow plain HTTP (if you are in a trusted network)")
218 return transferErr
219 }
220
221 return nil
222}
223
224func doTransfer(ctx context.Context, client *containerd.Client, src, dst interface{}, quiet bool, progressWriter io.Writer) error {
225 opts := make([]transfer.Opt, 0, 1)

Callers 1

PushFunction · 0.92

Calls 7

IsErrConnectionRefusedFunction · 0.92
IsErrTLSHandshakeFailureFunction · 0.92
preparePushStoreFunction · 0.85
createOCIRegistryFunction · 0.85
doTransferFunction · 0.85
InfoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…