MCPcopy
hub / github.com/containerd/containerd / Fetch

Method Fetch

client/client.go:483–519  ·  view source on GitHub ↗

Fetch downloads the provided content into containerd's content store and returns a non-platform specific image reference

(ctx context.Context, ref string, opts ...RemoteOpt)

Source from the content-addressed store, hash-verified

481// Fetch downloads the provided content into containerd's content store
482// and returns a non-platform specific image reference
483func (c *Client) Fetch(ctx context.Context, ref string, opts ...RemoteOpt) (images.Image, error) {
484 fetchCtx := defaultRemoteContext()
485 for _, o := range opts {
486 if err := o(c, fetchCtx); err != nil {
487 return images.Image{}, err
488 }
489 }
490
491 if fetchCtx.Unpack {
492 return images.Image{}, fmt.Errorf("unpack on fetch not supported, try pull: %w", errdefs.ErrNotImplemented)
493 }
494
495 if fetchCtx.PlatformMatcher == nil {
496 if len(fetchCtx.Platforms) == 0 {
497 fetchCtx.PlatformMatcher = platforms.All
498 } else {
499 ps, err := platforms.ParseAll(fetchCtx.Platforms)
500 if err != nil {
501 return images.Image{}, err
502 }
503
504 fetchCtx.PlatformMatcher = platforms.Any(ps...)
505 }
506 }
507
508 ctx, done, err := c.WithLease(ctx)
509 if err != nil {
510 return images.Image{}, err
511 }
512 defer done(ctx)
513
514 img, err := c.fetch(ctx, fetchCtx, ref, 0)
515 if err != nil {
516 return images.Image{}, err
517 }
518 return c.createNewImage(ctx, img)
519}
520
521// Push uploads the provided content to a remote resource
522func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpt) error {

Callers

nothing calls this directly

Calls 4

WithLeaseMethod · 0.95
fetchMethod · 0.95
createNewImageMethod · 0.95
defaultRemoteContextFunction · 0.85

Tested by

no test coverage detected