Skip to content

Conversation

@nimdrak
Copy link

@nimdrak nimdrak commented Oct 25, 2025

This commit introduces a new constructor, NewArtifactStoreWithEventCallback, to allow external consumers to register a callback function for artifact-related events.

The following methods now invoke the event callback if one is provided:

  • Remove
  • Pull
  • Push
  • Add
  • Extract
  • ExtractTarStream

Fixes #27260 containers/podman#27324

@github-actions github-actions bot added the common Related to "common" package label Oct 25, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 25, 2025
@podmanbot
Copy link

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6451

@nimdrak nimdrak changed the title Fixed #27260 Add NewArtifactStoreWithEventCallback for events of artifact feat(libartifact): Add NewArtifactStoreWithEventCallback for artifact events Oct 26, 2025
Copy link
Contributor

@mtrmac mtrmac left a 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)
Copy link
Contributor

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 attrs field 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 eventType seems to be named “status” in the user.)

return NewArtifactStoreWithEventCallback(storePath, sc, nil)
}

func NewArtifactStoreWithEventCallback(storePath string, sc *types.SystemContext, eventCallback EventCallback) (*ArtifactStore, error) {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants