Added POST then PUT method
$ helm push --username mstore --password mstore --insecure-skip-tls-verify DIST/mstore-0.2.0.tgz oci://localhost:1025/mstore Pushed: localhost:1025/mstore/mstore:0.2.0 Digest: sha256:5a60793c9fc655e1940b00dac707632d7d3b32aad31a79acc41e65f9152e50fc
This commit is contained in:
@@ -60,6 +60,15 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
|||||||
func (hand *Handler) PostUpload(rctx *router.Context) {
|
func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||||
name, _ := rctx.GetSubpath("name")
|
name, _ := rctx.GetSubpath("name")
|
||||||
|
|
||||||
|
hand.DumpHeaders("PostUploads", rctx)
|
||||||
|
|
||||||
|
authorization := rctx.GetHeader("Authorization")
|
||||||
|
if authorization == "" {
|
||||||
|
rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`)
|
||||||
|
rctx.SetStatus(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
digest := rctx.GetQuery("digest")
|
digest := rctx.GetQuery("digest")
|
||||||
mount := rctx.GetQuery("mount")
|
mount := rctx.GetQuery("mount")
|
||||||
from := rctx.GetQuery("from")
|
from := rctx.GetQuery("from")
|
||||||
@@ -150,6 +159,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
|||||||
reference, _ := rctx.GetSubpath("reference")
|
reference, _ := rctx.GetSubpath("reference")
|
||||||
|
|
||||||
digest := rctx.GetQuery("digest")
|
digest := rctx.GetQuery("digest")
|
||||||
|
reader := rctx.Request.Body
|
||||||
|
|
||||||
params := &operator.PutUploadParams{
|
params := &operator.PutUploadParams{
|
||||||
ContentLength: contentLength,
|
ContentLength: contentLength,
|
||||||
@@ -158,6 +168,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
|||||||
Name: name,
|
Name: name,
|
||||||
Reference: reference,
|
Reference: reference,
|
||||||
Digest: digest,
|
Digest: digest,
|
||||||
|
Reader: reader,
|
||||||
}
|
}
|
||||||
// Rigth checking
|
// Rigth checking
|
||||||
operatorID, _ := rctx.GetString(userTag)
|
operatorID, _ := rctx.GetString(userTag)
|
||||||
|
|||||||
+12
-2
@@ -217,10 +217,20 @@ func (oper *Operator) PutUpload(ctx context.Context, operatorID string, params *
|
|||||||
|
|
||||||
}
|
}
|
||||||
if contentLength != 0 {
|
if contentLength != 0 {
|
||||||
// TODO
|
recsize, _, err := oper.store.WriteUpload(params.Reference, params.Reader)
|
||||||
err = fmt.Errorf("Unexpected Content-Length header: %s", params.ContentLength)
|
if err != nil {
|
||||||
return res, http.StatusInternalServerError, err
|
return res, http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
if contentLength != 0 && recsize != contentLength {
|
||||||
|
oper.store.RemoveUpload(params.Reference)
|
||||||
|
err = fmt.Errorf("Mismatch upload recorded size and content length")
|
||||||
|
return res, http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return res, http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
res.Location = fmt.Sprintf("/v2/%s/blobs/%s", params.Name, params.Digest)
|
||||||
|
}
|
||||||
|
|
||||||
err = oper.store.LinkUpload(params.Reference, params.Digest)
|
err = oper.store.LinkUpload(params.Reference, params.Digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user