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)
| 481 | // Fetch downloads the provided content into containerd's content store |
| 482 | // and returns a non-platform specific image reference |
| 483 | func (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 |
| 522 | func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpt) error { |
nothing calls this directly
no test coverage detected