data.oci_model: sloppily rewrite digest format
We expect digests to be in the form 'sha256:digest'
This commit is contained in:
parent
2c8930c912
commit
9c0cbbf57c
5 changed files with 41 additions and 10 deletions
|
@ -14,6 +14,12 @@ LIST_MEDIA_TYPE = 'application/vnd.cnr.manifest.list.v0.json'
|
|||
SCHEMA_VERSION = 'v0'
|
||||
|
||||
|
||||
def _ensure_sha256_header(digest):
|
||||
if digest.startswith('sha256:'):
|
||||
return digest
|
||||
return 'sha256:' + digest
|
||||
|
||||
|
||||
def get_app_release(repo, tag_name, media_type):
|
||||
""" Returns (tag, manifest, blob) given a repo object, tag_name, and media_type). """
|
||||
tag = tag_model.get_tag(repo, tag_name, tag_kind='release')
|
||||
|
@ -67,7 +73,8 @@ def create_app_release(repo, tag_name, manifest, digest):
|
|||
(ManifestBlob
|
||||
.select()
|
||||
.join(Blob)
|
||||
.where(ManifestBlob.manifest == manifest, Blob.digest == blob_digest).get())
|
||||
.where(ManifestBlob.manifest == manifest,
|
||||
Blob.digest == _ensure_sha256_header(blob_digest)).get())
|
||||
except ManifestBlob.DoesNotExist:
|
||||
blob = blob_model.get_blob(blob_digest)
|
||||
ManifestBlob.create(manifest=manifest, blob=blob)
|
||||
|
|
Reference in a new issue