-
Couldn't load subscription status.
- Fork 33
feat(libartifact): Add NewArtifactStoreWithEventCallback for artifact events #418
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6451 |
Fixes #27260 Signed-off-by: ByoungUk Lee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick skim, looking at the API. I didn’t actually review the implementation much at all.
Cc: @baude .
|
|
||
| var ErrEmptyArtifactName = errors.New("artifact name cannot be empty") | ||
|
|
||
| type EventCallback func(eventType, name, digest string, attrs map[string]string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can the type use value use a Go ~enum with named constants? That would also provide a location to potentially document anything non-obvious about the types.
- Overall, some documentation of the values (and promises, or lack of promises, or constraints) would be valuable; in particular, the
attrsfield is vague enough to be basically not consumable by Go code. If this structure is required / preferred by Podman’s event system and documented there, please say at least that. - (The
eventTypeseems to be named “status” in the user.)
| return NewArtifactStoreWithEventCallback(storePath, sc, nil) | ||
| } | ||
|
|
||
| func NewArtifactStoreWithEventCallback(storePath string, sc *types.SystemContext, eventCallback EventCallback) (*ArtifactStore, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct as far as it goes, but adding a new function for every option combination does not scale.
Most importantly, do we need a new function at all? In general, c/common makes no API promises. Is there an extra stability promise that libartifact made?
If we don’t need to promise API stability, just adding a parameter to the existing function would work… or an options struct, collecting all the not-conceptually-essential options, so that we have named parameters.
If we do want API stability, we probably want a mechanism that also allows meaningfully reporting errors, and does not expose a public struct: the generic Go default seems to be a “functional options” mechanism, maybe similar to image/signature/sigstore.NewSigner and its Option.
This commit introduces a new constructor,
NewArtifactStoreWithEventCallback, to allow external consumers to register a callback function forartifact-related events.The following methods now invoke the event callback if one is provided:
RemovePullPushAddExtractExtractTarStreamFixes #27260 containers/podman#27324