1
0
Fork 0
forked from forgejo/forgejo

Add GET and DELETE endpoints for Docker blob uploads (#21367)

This PR adds support for
https://docs.docker.com/registry/spec/api/#get-blob-upload
https://docs.docker.com/registry/spec/api/#delete-blob-upload

Both are not required by the OCI spec but some clients call these
endpoints.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
KN4CK3R 2022-10-07 17:30:59 +02:00 committed by GitHub
parent d94f15c2fd
commit 69fc510d6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 5 deletions

View file

@ -316,8 +316,10 @@ func ContainerRoutes(ctx gocontext.Context) *web.Route {
r.Group("/blobs/uploads", func() {
r.Post("", container.InitiateUploadBlob)
r.Group("/{uuid}", func() {
r.Get("", container.GetUploadBlob)
r.Patch("", container.UploadBlob)
r.Put("", container.EndUploadBlob)
r.Delete("", container.CancelUploadBlob)
})
}, reqPackageAccess(perm.AccessModeWrite))
r.Group("/blobs/{digest}", func() {
@ -377,7 +379,7 @@ func ContainerRoutes(ctx gocontext.Context) *web.Route {
}
m := blobsUploadsPattern.FindStringSubmatch(path)
if len(m) == 3 && (isPut || isPatch) {
if len(m) == 3 && (isGet || isPut || isPatch || isDelete) {
reqPackageAccess(perm.AccessModeWrite)(ctx)
if ctx.Written() {
return
@ -391,10 +393,14 @@ func ContainerRoutes(ctx gocontext.Context) *web.Route {
ctx.SetParams("uuid", m[2])
if isPatch {
if isGet {
container.GetUploadBlob(ctx)
} else if isPatch {
container.UploadBlob(ctx)
} else {
} else if isPut {
container.EndUploadBlob(ctx)
} else {
container.CancelUploadBlob(ctx)
}
return
}