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

Support for OCI 1.1+ referrers via API #1546

Merged
merged 7 commits into from
Feb 3, 2023

Conversation

jdolitsky
Copy link
Contributor

@jdolitsky jdolitsky commented Jan 27, 2023

Follow-up to #1543, use the referrers API endpoint if the registry supports it, otherwise fallback to digest tag

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
@jdolitsky jdolitsky marked this pull request as ready for review February 1, 2023 17:00
@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2023

Codecov Report

Merging #1546 (c59bd0f) into main (da1008f) will decrease coverage by 0.18%.
The diff coverage is 67.73%.

@@            Coverage Diff             @@
##             main    #1546      +/-   ##
==========================================
- Coverage   73.07%   72.90%   -0.18%     
==========================================
  Files         117      118       +1     
  Lines        9082     9364     +282     
==========================================
+ Hits         6637     6827     +190     
- Misses       1780     1845      +65     
- Partials      665      692      +27     
Impacted Files Coverage Δ
pkg/v1/manifest.go 100.00% <ø> (ø)
pkg/v1/remote/delete.go 58.62% <ø> (ø)
pkg/v1/mutate/mutate.go 69.57% <32.00%> (-3.24%) ⬇️
pkg/v1/remote/referrers.go 40.00% <40.00%> (ø)
pkg/v1/remote/write.go 62.43% <55.33%> (-1.69%) ⬇️
pkg/v1/remote/descriptor.go 72.34% <58.49%> (-1.94%) ⬇️
pkg/registry/manifest.go 94.04% <100.00%> (+1.83%) ⬆️
pkg/registry/registry.go 100.00% <100.00%> (ø)
pkg/v1/mutate/image.go 69.56% <100.00%> (+0.33%) ⬆️
pkg/v1/mutate/index.go 79.33% <100.00%> (+0.34%) ⬆️
... and 5 more

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

Copy link
Collaborator

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

Can we add support for referrers to pkg/registry, and use that to test this path?

pkg/v1/remote/descriptor.go Outdated Show resolved Hide resolved
pkg/registry/manifest.go Fixed Show fixed Hide fixed
pkg/registry/manifest.go Fixed Show fixed Hide fixed
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
Comment on lines +112 to +117
// WithReferrersSupport enables the referrers API endpoint (OCI 1.1+)
func WithReferrersSupport(enabled bool) Option {
return func(r *registry) {
r.referrersEnabled = enabled
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is disabled by default, but we could go the other direction too

Copy link
Collaborator

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

Very nice! I think we could merge like this, just a couple questions. (edit: one question.)

Comment on lines +585 to +605
// Check if the registry supports Referrers API.
// TODO: This should be done once per registry, not once per subject.
u := w.url(fmt.Sprintf("/v2/%s/referrers/%s", w.repo.RepositoryStr(), sub.DigestStr()))
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return err
}
req.Header.Set("Accept", string(types.OCIImageIndex))
resp, err := w.client.Do(req.WithContext(ctx))
if err != nil {
return err
}
defer resp.Body.Close()

if err := transport.CheckError(resp, http.StatusOK, http.StatusNotFound, http.StatusBadRequest); err != nil {
return err
}
if resp.StatusCode == http.StatusOK {
// The registry supports Referrers API. The registry is responsible for updating the referrers list.
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds like this will all go away once opencontainers/distribution-spec#379 is in, do we want to just start supporting that in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think id rather see it merged first, then come back to change here

@imjasonh
Copy link
Collaborator

imjasonh commented Feb 3, 2023

I'll let @jonjohnsonjr clickey the mergey

@jonjohnsonjr jonjohnsonjr merged commit b3c23b4 into google:main Feb 3, 2023
@jdolitsky jdolitsky deleted the oci-1-1-w-api branch February 3, 2023 22:32
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.

None yet

4 participants