app/imageoper, app/maindb: one image - one arch; app/storage: blob to name subdir
This commit is contained in:
+14
-16
@@ -111,21 +111,26 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
name := params.Name
|
||||
reference := params.Reference
|
||||
|
||||
arch := inMan.Subject.Platform.Architecture
|
||||
os := inMan.Subject.Platform.OS
|
||||
variant := inMan.Subject.Platform.Variant
|
||||
/*
|
||||
arch := inMan.Subject.Platform.Architecture
|
||||
os := inMan.Subject.Platform.OS
|
||||
variant := inMan.Subject.Platform.Variant
|
||||
|
||||
manexist, exMandescr, err := oper.mdb.GetManifestsByReferenceArchitecture(ctx, name, reference, arch, os, variant)
|
||||
manexist, exMandescr, err := oper.mdb.GetManifestsByReferenceArchitecture(ctx, name, reference, arch, os, variant)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
*/
|
||||
manexist, exMandescr, err := oper.mdb.GetManifestByReference(ctx, name, reference)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
inManDescr, inlayerdescrs, err := descrsFromManifest(name, reference, inMan, inManData)
|
||||
inManDescr.Digest = digstr
|
||||
// Always check layer files for availability
|
||||
var blobError error
|
||||
for _, blobDescr := range inlayerdescrs {
|
||||
blobExists, _, err := oper.store.BlobExists(blobDescr.Digest)
|
||||
blobExists, _, err := oper.store.BlobExists(blobDescr.Name, blobDescr.Digest)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -151,7 +156,6 @@ func (oper *Operator) PutManifest(ctx context.Context, params *PutManifestParams
|
||||
return res, http.StatusCreated, err
|
||||
}
|
||||
*/
|
||||
|
||||
exManData := []byte(exMandescr.Payload)
|
||||
exMan := &ocispec.Manifest{}
|
||||
err := json.Unmarshal(exManData, exMan)
|
||||
@@ -163,25 +167,22 @@ 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, &inManDescr, addedBlobDescrs, uselessBlobDescrs)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
//goto end
|
||||
for _, blob := range uselessBlobDescrs {
|
||||
exists, _, err := oper.store.BlobExists(blob.Digest)
|
||||
exists, _, err := oper.store.BlobExists(blob.Name, blob.Digest)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
blobUsage, err := oper.mdb.GetBlobUsage(ctx, blob.Digest)
|
||||
blobUsage, err := oper.mdb.GetBlobUsage(ctx, blob.Name, blob.Digest)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
if exists && blobUsage == 0 {
|
||||
err = oper.store.DeleteBlob(blob.Digest)
|
||||
err = oper.store.DeleteBlob(blob.Name, blob.Digest)
|
||||
if err != nil {
|
||||
return res, http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -202,9 +203,6 @@ 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user