@@ -63,6 +63,7 @@ import (
6363 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
6464 specs "github.com/opencontainers/runtime-spec/specs-go"
6565 "github.com/pkg/errors"
66+ "golang.org/x/sync/semaphore"
6667 "google.golang.org/grpc"
6768 "google.golang.org/grpc/backoff"
6869 "google.golang.org/grpc/health/grpc_health_v1"
@@ -355,6 +356,9 @@ type RemoteContext struct {
355356 // MaxConcurrentDownloads is the max concurrent content downloads for each pull.
356357 MaxConcurrentDownloads int
357358
359+ // MaxConcurrentUploadedLayers is the max concurrent uploaded layers for each push.
360+ MaxConcurrentUploadedLayers int
361+
358362 // AllMetadata downloads all manifests and known-configuration files
359363 AllMetadata bool
360364
@@ -463,7 +467,12 @@ func (c *Client) Push(ctx context.Context, ref string, desc ocispec.Descriptor,
463467 wrapper = pushCtx .HandlerWrapper
464468 }
465469
466- return remotes .PushContent (ctx , pusher , desc , c .ContentStore (), pushCtx .PlatformMatcher , wrapper )
470+ var limiter * semaphore.Weighted
471+ if pushCtx .MaxConcurrentUploadedLayers > 0 {
472+ limiter = semaphore .NewWeighted (int64 (pushCtx .MaxConcurrentUploadedLayers ))
473+ }
474+
475+ return remotes .PushContent (ctx , pusher , desc , c .ContentStore (), limiter , pushCtx .PlatformMatcher , wrapper )
467476}
468477
469478// GetImage returns an existing image
0 commit comments