Merge pull request #3196 from quay/joseph.schorr/QUAY-1021/manifest-links

Allow lookup of "dead" manifests so manifest links can be clicked in the tag history
This commit is contained in:
Joseph Schorr 2018-08-09 16:32:25 -04:00 committed by GitHub
commit ad03404d31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -649,9 +649,9 @@ def delete_manifest_by_digest(namespace, repo_name, digest):
return [tag_manifest.tag for tag_manifest in tag_manifests]
def load_manifest_by_digest(namespace, repo_name, digest):
def load_manifest_by_digest(namespace, repo_name, digest, allow_dead=False):
try:
return (_load_repo_manifests(namespace, repo_name)
return (_load_repo_manifests(namespace, repo_name, allow_dead=allow_dead)
.where(TagManifest.digest == digest)
.get())
except TagManifest.DoesNotExist:
@ -659,8 +659,8 @@ def load_manifest_by_digest(namespace, repo_name, digest):
raise InvalidManifestException(msg)
def _load_repo_manifests(namespace, repo_name):
return _tag_alive(TagManifest
def _load_repo_manifests(namespace, repo_name, allow_dead=False):
query = (TagManifest
.select(TagManifest, RepositoryTag)
.join(RepositoryTag)
.join(Image)
@ -668,6 +668,10 @@ def _load_repo_manifests(namespace, repo_name):
.join(Namespace, on=(Namespace.id == Repository.namespace_user))
.where(Repository.name == repo_name, Namespace.username == namespace))
if not allow_dead:
query = _tag_alive(query)
return query
def change_repository_tag_expiration(namespace_name, repo_name, tag_name, expiration_date):
""" Changes the expiration of the tag with the given name to the given expiration datetime. If

View file

@ -41,7 +41,8 @@ class ManifestLabelPreOCI(ManifestLabelInterface):
def get_repository_manifest(self, namespace_name, repository_name, digest):
try:
tag_manifest = model.tag.load_manifest_by_digest(namespace_name, repository_name, digest)
tag_manifest = model.tag.load_manifest_by_digest(namespace_name, repository_name, digest,
allow_dead=True)
except model.DataModelException:
return None