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

refactor: optimize extended copy filters #335

Merged
merged 4 commits into from
Sep 30, 2022

Conversation

Wwwsylvia
Copy link
Member

@Wwwsylvia Wwwsylvia commented Sep 28, 2022

According to Open Container Initiative Distribution Specification, the Referrers API must include the artifact type and annotations of the referrers in the returned descriptor list.

The descriptors MUST include an artifactType field that is set to the value of artifactType for an artifact manifest if present, or the configuration descriptor's mediaType for an image manifest. The descriptors MUST include annotations from the image or artifact manifest.

However, the Predecessors function implemented by file, OCI, and memory store is not guaranteed to include the artifact type and annotations in the returned descriptors.

This PR is migrated from oci-playground#3.

Resolves #310
Signed-off-by: Lixia (Sylvia) Lei lixlei@microsoft.com

@Wwwsylvia
Copy link
Member Author

This PR is migrated from oci-playground#3.

extendedcopy.go Outdated Show resolved Hide resolved
extendedcopy.go Outdated Show resolved Hide resolved
extendedcopy.go Outdated Show resolved Hide resolved
extendedcopy.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #335 (bbfd844) into main (c1f42a4) will decrease coverage by 0.05%.
The diff coverage is 64.94%.

@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
- Coverage   72.18%   72.13%   -0.06%     
==========================================
  Files          38       38              
  Lines        3635     3678      +43     
==========================================
+ Hits         2624     2653      +29     
- Misses        752      764      +12     
- Partials      259      261       +2     
Impacted Files Coverage Δ
content/graph.go 0.00% <0.00%> (ø)
extendedcopy.go 70.28% <69.23%> (+1.31%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

extendedcopy.go Outdated Show resolved Hide resolved
extendedcopy.go Outdated
Comment on lines 276 to 278
filter := func(desc ocispec.Descriptor) bool {
return regex.MatchString(desc.ArtifactType)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above in FilterAnnotation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, we can have something like

func (opts *ExtendedCopyGraphOptions) MatchArtifactType(artifactType string) {

Copy link
Member Author

@Wwwsylvia Wwwsylvia Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

func (opts *ExtendedCopyGraphOptions) SelectArtifactType(artifactType string) {

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add this into rc.5.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

select: v. carefully choose as being the best or most suitable.
match: v. be equal to (something) in quality or strength.

Basically, to select, you need a list of items first :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create an issue in rc.5 to track it.

extendedcopy.go Outdated Show resolved Hide resolved
extendedcopy.go Outdated Show resolved Hide resolved
@Wwwsylvia Wwwsylvia changed the title refactor: optimize extended copy filter refactor: optimize extended copy filters Sep 30, 2022
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Wwwsylvia
Copy link
Member Author

Wwwsylvia and others added 4 commits September 30, 2022 11:54
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Wwwsylvia Wwwsylvia merged commit 38b39d3 into oras-project:main Sep 30, 2022
@Wwwsylvia Wwwsylvia deleted the extendedcopy_squash branch September 30, 2022 04:19
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 this pull request may close these issues.

Improve performance of filters of oras.ExtendedCopy() caused by information loss due to descriptor conversions
3 participants