repocli: first version of pull & push image
This commit is contained in:
@@ -52,7 +52,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
|
||||
|
||||
accountID = terms.AnonymousID
|
||||
|
||||
hand.logg.Debugf("URL: %s", rctx.URL().String())
|
||||
//hand.logg.Debugf("URL: %s", rctx.URL().String())
|
||||
authHeader := rctx.GetHeader("Authorization")
|
||||
hand.logg.Debugf("Authorization: %s", authHeader)
|
||||
if authHeader != "" {
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
||||
func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
|
||||
hand.DumpHeaders("PostUploads", rctx)
|
||||
//hand.DumpHeaders("PostUploads", rctx)
|
||||
|
||||
authorization := rctx.GetHeader("Authorization")
|
||||
if authorization == "" {
|
||||
|
||||
@@ -88,6 +88,7 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
}
|
||||
|
||||
incomingManifestBytes := buffer.Bytes()
|
||||
|
||||
if int64(len(incomingManifestBytes)) != contentLength {
|
||||
err = fmt.Errorf("Mismatch Content-Length and received manifest size: %d vs %d",
|
||||
contentLength, len(incomingManifestBytes))
|
||||
@@ -163,11 +164,14 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
// Starting manifest and blobs transaction
|
||||
err = oper.mdb.UpdateManifestWithBlobs(ctx, &incomingManifestDescr, addedBlobDescrs, uselessBlobDescrs)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
//goto end
|
||||
for _, blob := range uselessBlobDescrs {
|
||||
exists, _, err := oper.store.BlobExists(blob.Digest)
|
||||
if err != nil {
|
||||
@@ -201,6 +205,8 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
}
|
||||
}
|
||||
|
||||
//end:
|
||||
|
||||
res.Location = fmt.Sprintf(`/v2/%s/manifests/%s`, params.Name, params.Reference)
|
||||
return res, http.StatusCreated, err
|
||||
}
|
||||
|
||||
@@ -129,7 +129,8 @@ func (db *Database) UpdateManifestWithBlobs(ctx context.Context, manifest *descr
|
||||
|
||||
// Manifest
|
||||
request = `UPDATE manifests SET contentType = $1, payload = $2, digest = $3, updated_at = $4, updated_by = $5
|
||||
WHERE name = $6 AND reference = $7, architecture = $8, os = $9, variant = $10`
|
||||
WHERE name = $6 AND reference = $7
|
||||
AND architecture = $8 AND os = $9 AND variant = $10`
|
||||
_, err = tx.Exec(request, manifest.ContentType, manifest.Payload, manifest.Digest,
|
||||
manifest.UpdatedAt, manifest.UpdatedBy,
|
||||
manifest.Name, manifest.Reference,
|
||||
|
||||
@@ -97,7 +97,7 @@ func (svc *Service) Build() error {
|
||||
|
||||
svc.rout.Post(`/v2/{name}/blobs/uploads/`, svc.hand.PostUpload)
|
||||
svc.rout.Patch(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PatchUpload)
|
||||
svc.rout.Put(`/v2/{name}/uploads/{reference}`, svc.hand.PutUpload)
|
||||
svc.rout.Put(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PutUpload)
|
||||
|
||||
svc.rout.Get(`/v2/{name}/blobs/{digest}`, svc.hand.GetBlob)
|
||||
svc.rout.Delete(`/v2/{name}/blobs/{digest}`, svc.hand.DeleteBlob)
|
||||
|
||||
Reference in New Issue
Block a user