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

Request: Add Public Function for Finding Referrers and Filtering by Artifact Type #657

Closed
nathan-joslin opened this issue Dec 13, 2023 · 5 comments · Fixed by #659
Closed

Comments

@nathan-joslin
Copy link

User Story

As a user of oras-go I would like to discover referrers of a manifest and filter by ArtifactType. I have a GraphStorage which only gives me access to Predecessors. I'd like to take advantage of the referrers API for optimization.

Limits of Current Functionality

The FilterArtifactType option for ExtendedCopyGraph provides this filtering, but the condition of copying limits its use.

As the GraphStorage I have is originally a registry.Repository, I have the option of elevating my GraphStorage to a registry.Repository giving me access to repository.Referrers. However, this has a side effect on my unit tests which use a memory.Store; a PredecessorFinder not a registry.ReferrerLister.

The implementation of func (opts *ExendedCopyGraphOptions) FilterArtifactType(regex) provides a "fallback" mechanism, where a non registry.ReferrerLister uses Predecessors instead, which seems useful to both the memory.Store in my unit tests as well as my GraphStorage.

@nathan-joslin
Copy link
Author

Perhaps a duplicate of issue 392

@Wwwsylvia
Copy link
Member

Hi @nathan-joslin , thanks for opening the issue.
We would like to gain a better understanding of your use cases. Are there any other scenarios where Referrers and FilterArtifactType are required, besides in unit testing?

@nathan-joslin
Copy link
Author

@Wwwsylvia Apologies for the confusion. My use case is not within a unit test. I have a GraphStorage where I'd like to fetch manifests of a particular ArtifactType. As I only have access to Predecessors with a GraphStorage, I have to filter by ArtifactType myself, which does not take advantage of the referrers API.

I noticed similar existing implementations of using the referrers API with ReadOnlyGraphStorages. For instance the Referrers function in oras (also referenced in issue 392), and the FilterArtifactType option in oras-go. The first implementation does not apply to my use case as it's not oras-go and internal. The second implementation must be used by ExtendedCopyGraph, which does not apply to my use case as I do not wish to copy to a destination GraphStorage.

The related issue 392 proposes letting content.Stores implement registry.ReferrerLister because they have access to Predecessors. I believe a similar proposal should be made for GraphStorages as they also have access to Predecessors.

@shizhMSFT
Copy link
Contributor

I think this issue can be potentially resolved by #659 as per #659 (comment).

@nathan-joslin
Copy link
Author

I agree with your comment.

@yizha1 yizha1 linked a pull request Dec 26, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants