feat: index referrers when pushing manifests#35
feat: index referrers when pushing manifests#35shizhMSFT merged 5 commits intooras-project:mainfrom wangxiaoxuan273:index-referrers
Conversation
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
|
|
||
| // TODO: Should be removed and defined instead in paths package | ||
| // Requires paths package to be exported | ||
| func referrersLinkPath(name string) string { |
There was a problem hiding this comment.
Need advice on how to handle these. Move them to the path package?
There was a problem hiding this comment.
@wangxiaoxuan273 Yes, please move them to the path package and update the related documentation.
Codecov Report
@@ Coverage Diff @@
## main #35 +/- ##
==========================================
- Coverage 57.18% 57.18% -0.01%
==========================================
Files 107 107
Lines 10990 11021 +31
==========================================
+ Hits 6285 6302 +17
- Misses 4001 4011 +10
- Partials 704 708 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
| rootPath := path.Join(referrersLinkPath(ms.repository.Named().Name()), subjectRevision.Algorithm().String(), subjectRevision.Hex()) | ||
| referenceLinkPath := path.Join(rootPath, revision.Algorithm().String(), revision.Hex(), "link") |
There was a problem hiding this comment.
What would be proper path considering referrers is a first-class item like manifests, blobs?
There was a problem hiding this comment.
How would it be impacted if we delete a repository?
There was a problem hiding this comment.
Also think about how artifact type can be supported.
Hint: Hashing will be useful for user input projection.
There was a problem hiding this comment.
Currently, only PUT path is considered. How about the DELETE path in terms of indexing referrers?
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
| // | ||
| // The path layout in the storage backend is roughly as follows: | ||
| // | ||
| // <root>/v2 |
There was a problem hiding this comment.
All these formatting changes are auto-generated by the go formatter when saving the file.
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
registry/storage/paths.go
Outdated
| // Referrers: | ||
| // | ||
| // blobsPathSpec: <root>/v2/blobs/ | ||
| // blobPathSpec: <root>/v2/blobs/<algorithm>/<first two hex bytes of digest>/<hex digest> | ||
| // blobDataPathSpec: <root>/v2/blobs/<algorithm>/<first two hex bytes of digest>/<hex digest>/data | ||
| // blobMediaTypePathSpec: <root>/v2/blobs/<algorithm>/<first two hex bytes of digest>/<hex digest>/data | ||
| // referrersLinkPathSpec: <root>/v2/repositories/<name>/_referrers/<algorithm>/<hex digest>/<subject algorithm>/<subject hex digest>/link |
| // hashstates/<algorithm>/<offset> | ||
| // -> blob/<algorithm> | ||
| // <split directory content addressable storage> | ||
| // <root>/v2 |
There was a problem hiding this comment.
referrer related paths should also be here.
There was a problem hiding this comment.
Please check if line 43-45 are correct.
registry/storage/paths.go
Outdated
| if err != nil { | ||
| return "", err | ||
| } | ||
| return path.Join(append(append(append(append(repoPrefix, v.name, "_referrers", "subjects"), revisionComponents...), subjectComponents...), "link")...), nil |
There was a problem hiding this comment.
4 x append do not seem right. Could you rewrite it to multiple lines?
registry/storage/paths.go
Outdated
| // We cover the path formats implemented by this path mapper below. | ||
| // | ||
| // Manifests: | ||
| // Manifests: |
There was a problem hiding this comment.
Should it just one tab?
| // Manifests: | |
| // Manifests: |
| if err := ms.storageDriver.PutContent(ctx, referrersLinkPath, []byte(revision.String())); err != nil { | ||
| return err | ||
| } | ||
| return nil |
There was a problem hiding this comment.
nit:
| if err := ms.storageDriver.PutContent(ctx, referrersLinkPath, []byte(revision.String())); err != nil { | |
| return err | |
| } | |
| return nil | |
| return ms.storageDriver.PutContent(ctx, referrersLinkPath, []byte(revision.String())) |
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Part 6 of #21
This pr implements indexing referrers during manifest push. This is needed to enable the referrers API. It changes the
registry/storagepackage. Based on the existing implementation on the rc2 branch.Signed-off-by: wangxiaoxuan273 wangxiaoxuan119@gmail.com