MCPcopy
hub / github.com/containerd/containerd / Push

Method Push

client/client.go:522–571  ·  view source on GitHub ↗

Push uploads the provided content to a remote resource

(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpt)

Source from the content-addressed store, hash-verified

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 {
523 pushCtx := defaultRemoteContext()
524 for _, o := range opts {
525 if err := o(c, pushCtx); err != nil {
526 return err
527 }
528 }
529 if pushCtx.PlatformMatcher == nil {
530 if len(pushCtx.Platforms) > 0 {
531 ps, err := platforms.ParseAll(pushCtx.Platforms)
532 if err != nil {
533 return err
534 }
535 pushCtx.PlatformMatcher = platforms.Any(ps...)
536 } else {
537 pushCtx.PlatformMatcher = platforms.All
538 }
539 }
540
541 // Annotate ref with digest to push only push tag for single digest
542 if !strings.Contains(ref, "@") {
543 ref = ref + "@" + desc.Digest.String()
544 }
545
546 pusher, err := pushCtx.Resolver.Pusher(ctx, ref)
547 if err != nil {
548 return err
549 }
550
551 var wrapper func(images.Handler) images.Handler
552
553 if len(pushCtx.BaseHandlers) > 0 {
554 wrapper = func(h images.Handler) images.Handler {
555 h = images.Handlers(append(pushCtx.BaseHandlers, h)...)
556 if pushCtx.HandlerWrapper != nil {
557 h = pushCtx.HandlerWrapper(h)
558 }
559 return h
560 }
561 } else if pushCtx.HandlerWrapper != nil {
562 wrapper = pushCtx.HandlerWrapper
563 }
564
565 var limiter *semaphore.Weighted
566 if pushCtx.MaxConcurrentUploadedLayers > 0 {
567 limiter = semaphore.NewWeighted(int64(pushCtx.MaxConcurrentUploadedLayers))
568 }
569
570 return remotes.PushContent(ctx, pusher, desc, c.ContentStore(), limiter, pushCtx.PlatformMatcher, wrapper)
571}
572
573// GetImage returns an existing image
574func (c *Client) GetImage(ctx context.Context, ref string) (Image, error) {

Callers

nothing calls this directly

Calls 6

ContentStoreMethod · 0.95
HandlersFunction · 0.92
PushContentFunction · 0.92
defaultRemoteContextFunction · 0.85
PusherMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected