Skip to content

feat!: implement the referrers route in the v2 package#32

Merged
shizhMSFT merged 3 commits intooras-project:mainfrom
wangxiaoxuan273:v2-pkg
Nov 4, 2022
Merged

feat!: implement the referrers route in the v2 package#32
shizhMSFT merged 3 commits intooras-project:mainfrom
wangxiaoxuan273:v2-pkg

Conversation

@wangxiaoxuan273
Copy link
Copy Markdown

Implement the referrers route in the registry/api/v2 package. Path with filtering on ArtifactType is also implemented. Unit tests are included. The next pr will implement referrersHandler but probably will not implement filtering yet.

Part 5 of #21

Signed-off-by: wangxiaoxuan273 wangxiaoxuan119@gmail.com

@wangxiaoxuan273 wangxiaoxuan273 changed the title feat!: implement referrers route in the v2 package feat!: implement the referrers route in the v2 package Oct 31, 2022
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 31, 2022

Codecov Report

Merging #32 (2a611e0) into main (0e64ff7) will increase coverage by 0.00%.
The diff coverage is 62.50%.

@@           Coverage Diff           @@
##             main      #32   +/-   ##
=======================================
  Coverage   57.18%   57.18%           
=======================================
  Files         107      107           
  Lines       10982    10990    +8     
=======================================
+ Hits         6280     6285    +5     
- Misses       3999     4001    +2     
- Partials      703      704    +1     
Impacted Files Coverage Δ
registry/api/v2/descriptors.go 100.00% <ø> (ø)
registry/api/v2/routes.go 100.00% <ø> (ø)
registry/api/v2/urls.go 75.30% <62.50%> (-0.67%) ⬇️

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

Description: "Fetch the referrers of the artifact identified by `digest`.",
Requests: []RequestDescriptor{
{
Name: "referrers",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit:

Suggested change
Name: "referrers",
Name: "Referrers",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changed.

Comment on lines +1626 to +1633
Format: `{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
<manifest>,
...
]
}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The indentation is not correct.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks OK on editor.🤔

linkHeader,
},
Body: BodyDescriptor{
ContentType: "application/json",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should it be application/vnd.oci.image.index.v1+json?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

replaced.

Comment on lines +1638 to +1641
{
Description: "The registry does not support referrers API.",
StatusCode: http.StatusNotFound,
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It is also possible that the repository does not exists.

/cc @Wwwsylvia @m5i-work

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should return 404 and error code NAME_UNKNOWN when the repository does not exist.
References:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added the variable repositoryNotFoundResponseDescriptor defined in descriptors.go to address this scenario. It satisfies your specifications.
image
Now the Failures responses look like this, note the added line:
image

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Copy link
Copy Markdown

@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

@shizhMSFT shizhMSFT merged commit 6f0e3ea into oras-project:main Nov 4, 2022
@wangxiaoxuan273 wangxiaoxuan273 deleted the v2-pkg branch November 4, 2022 09:41
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.

4 participants