Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finalizer on Pusher returned by Resolver? #172

Closed
deitch opened this issue Jul 30, 2020 · 1 comment · Fixed by #394
Closed

finalizer on Pusher returned by Resolver? #172

deitch opened this issue Jul 30, 2020 · 1 comment · Fixed by #394
Milestone

Comments

@deitch
Copy link
Contributor

deitch commented Jul 30, 2020

Looking at how oras.Push() is called here, we pass it a remotes.Resolver:

func Push(ctx context.Context, resolver remotes.Resolver, ref string, provider content.Provider, descriptors []ocispec.Descriptor, opts ...PushOpt) (ocispec.Descriptor, error) {

Push() , in turn, gets a pusher by calling resolver.Pusher() here

	pusher, err := resolver.Pusher(ctx, ref)

and then passing that pusher to remotes.PushContent here:

	if err := remotes.PushContent(ctx, pusher, desc, store, nil, wrapper); err != nil {

What if my pusher (returned by resolver.Pusher()) needs some finalizing done? There are Commit() and Close() calls on the content.Writer returned by each Push(), but not overall. I might have a custom resolver (and therefore pusher) that needs to do some activity at the end of a whole PushContent.

remotes.PushContent() has an option for doing so via its handlers, which can be both pre- and post-, but oras.Push() only accepts pre-push handlers for each push, see here. In any case, those are called with each push, and so no way to know, "this is the final push".

I can do something at the Resolver level, rather than Pusher, and thus have control after calling oras.Push(), but that is one level too high for it, and could bleed into other things. For example, I should be able to push 3 images up, each time calling oras.Push() (and hence resolver.Pusher()) from the same instance of resolver; finalizing would really mess that up.

@shizhMSFT shizhMSFT added this to the v0.13.0 milestone May 7, 2022
@shizhMSFT
Copy link
Contributor

shizhMSFT commented May 7, 2022

We can close this once we move to oras-go v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants