Skip to content

Commit 840a657

Browse files
committed
Change PushContent to require only Provider
Before this required a full content.Store so that it could annotate distribution sources. With this change PushContent can be used with just a content.Provider. If the content.Provider is also a content.Manager then distribution sources will be updated accordingly. This allows people to use this function with a significantly implementation. Signed-off-by: Brian Goff <[email protected]>
1 parent 5d4276c commit 840a657

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

remotes/handlers.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ func push(ctx context.Context, provider content.Provider, pusher Pusher, desc oc
198198
//
199199
// Base handlers can be provided which will be called before any push specific
200200
// handlers.
201-
func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, store content.Store, limiter *semaphore.Weighted, platform platforms.MatchComparer, wrapper func(h images.Handler) images.Handler) error {
201+
//
202+
// If the passed in content.Provider is also a content.Manager then this will
203+
// also annotate the distribution sources in the manager.
204+
func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, store content.Provider, limiter *semaphore.Weighted, platform platforms.MatchComparer, wrapper func(h images.Handler) images.Handler) error {
202205

203206
var m sync.Mutex
204207
manifests := []ocispec.Descriptor{}
@@ -225,13 +228,14 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st
225228

226229
platformFilterhandler := images.FilterPlatforms(images.ChildrenHandler(store), platform)
227230

228-
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, store)
231+
var handler images.Handler
232+
if m, ok := store.(content.Manager); ok {
233+
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, m)
234+
handler = images.Handlers(annotateHandler, filterHandler, pushHandler)
235+
} else {
236+
handler = images.Handlers(platformFilterhandler, filterHandler, pushHandler)
237+
}
229238

230-
var handler images.Handler = images.Handlers(
231-
annotateHandler,
232-
filterHandler,
233-
pushHandler,
234-
)
235239
if wrapper != nil {
236240
handler = wrapper(handler)
237241
}

0 commit comments

Comments
 (0)