Closed nathan-joslin closed 9 months ago
Perhaps a duplicate of issue 392
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?
@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 ReadOnlyGraphStorage
s. 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.Store
s implement registry.ReferrerLister
because they have access to Predecessors. I believe a similar proposal should be made for GraphStorage
s as they also have access to Predecessors
.
I think this issue can be potentially resolved by #659 as per https://github.com/oras-project/oras-go/pull/659#discussion_r1429535685.
I agree with your comment.
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 toPredecessors
. I'd like to take advantage of the referrers API for optimization.Limits of Current Functionality
The
FilterArtifactType
option forExtendedCopyGraph
provides this filtering, but the condition of copying limits its use.As the
GraphStorage
I have is originally aregistry.Repository
, I have the option of elevating myGraphStorage
to aregistry.Repository
giving me access torepository.Referrers
. However, this has a side effect on my unit tests which use amemory.Store
; aPredecessorFinder
not aregistry.ReferrerLister
.The implementation of
func (opts *ExendedCopyGraphOptions) FilterArtifactType(regex)
provides a "fallback" mechanism, where a nonregistry.ReferrerLister
usesPredecessors
instead, which seems useful to both thememory.Store
in my unit tests as well as myGraphStorage
.