Push uploads the provided content to a remote resource
(ctx context.Context, ref string, desc ocispec.Descriptor, opts ...RemoteOpt)
| 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 { |
| 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 |
| 574 | func (c *Client) GetImage(ctx context.Context, ref string) (Image, error) { |
nothing calls this directly
no test coverage detected