aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/api.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-10-07 17:30:59 +0200
committerGitHub <noreply@github.com>2022-10-07 23:30:59 +0800
commit69fc510d6dcf9cda7993eae8cd5c7725b345a9a1 (patch)
tree3ad6e0f5a1d86cc57b6a7e9fb97fd46c97b095e4 /routers/api/packages/api.go
parentd94f15c2fd921722796a4cfdbbf266dd3017525c (diff)
downloadgitea-69fc510d6dcf9cda7993eae8cd5c7725b345a9a1.tar.gz
gitea-69fc510d6dcf9cda7993eae8cd5c7725b345a9a1.zip
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>
Diffstat (limited to 'routers/api/packages/api.go')
-rw-r--r--routers/api/packages/api.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go
index 3354fe12d4..0889006dd7 100644
--- a/routers/api/packages/api.go
+++ b/routers/api/packages/api.go
@@ -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
}