Skip to content

Support for OCI 1.1+ referrers via API#1546

Merged
jonjohnsonjr merged 7 commits intogoogle:mainfrom
jdolitsky:oci-1-1-w-api
Feb 3, 2023
Merged

Support for OCI 1.1+ referrers via API#1546
jonjohnsonjr merged 7 commits intogoogle:mainfrom
jdolitsky:oci-1-1-w-api

Conversation

@jdolitsky
Copy link
Copy Markdown
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
Copy Markdown

codecov-commenter commented Feb 1, 2023

Codecov Report

❌ Patch coverage is 85.31469% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.90%. Comparing base (da1008f) to head (c59bd0f).
⚠️ Report is 143 commits behind head on main.

Files with missing lines Patch % Lines
pkg/v1/remote/descriptor.go 67.56% 8 Missing and 4 partials ⚠️
pkg/v1/remote/write.go 62.50% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@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?

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
@jdolitsky jdolitsky requested a review from imjasonh February 2, 2023 18:50
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
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

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
Copy Markdown
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

@jdolitsky jdolitsky requested a review from imjasonh February 3, 2023 18:04
@imjasonh
Copy link
Copy Markdown
Contributor

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.

4 participants