Skip to content

Commit bef4145

Browse files
cpuguy83vvoland
authored andcommitted
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]> (cherry picked from commit 840a657) Signed-off-by: Paweł Gronowski <[email protected]>
1 parent fe33226 commit bef4145

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
@@ -197,7 +197,10 @@ func push(ctx context.Context, provider content.Provider, pusher Pusher, desc oc
197197
//
198198
// Base handlers can be provided which will be called before any push specific
199199
// handlers.
200-
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 {
200+
//
201+
// If the passed in content.Provider is also a content.Manager then this will
202+
// also annotate the distribution sources in the manager.
203+
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 {
201204

202205
var m sync.Mutex
203206
manifestStack := []ocispec.Descriptor{}
@@ -219,13 +222,14 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st
219222

220223
platformFilterhandler := images.FilterPlatforms(images.ChildrenHandler(store), platform)
221224

222-
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, store)
225+
var handler images.Handler
226+
if m, ok := store.(content.Manager); ok {
227+
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, m)
228+
handler = images.Handlers(annotateHandler, filterHandler, pushHandler)
229+
} else {
230+
handler = images.Handlers(platformFilterhandler, filterHandler, pushHandler)
231+
}
223232

224-
var handler images.Handler = images.Handlers(
225-
annotateHandler,
226-
filterHandler,
227-
pushHandler,
228-
)
229233
if wrapper != nil {
230234
handler = wrapper(handler)
231235
}

0 commit comments

Comments
 (0)