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] 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: try:
return (_load_repo_manifests(namespace, repo_name) return (_load_repo_manifests(namespace, repo_name, allow_dead=allow_dead)
.where(TagManifest.digest == digest) .where(TagManifest.digest == digest)
.get()) .get())
except TagManifest.DoesNotExist: except TagManifest.DoesNotExist:
@ -659,15 +659,19 @@ def load_manifest_by_digest(namespace, repo_name, digest):
raise InvalidManifestException(msg) raise InvalidManifestException(msg)
def _load_repo_manifests(namespace, repo_name): def _load_repo_manifests(namespace, repo_name, allow_dead=False):
return _tag_alive(TagManifest query = (TagManifest
.select(TagManifest, RepositoryTag) .select(TagManifest, RepositoryTag)
.join(RepositoryTag) .join(RepositoryTag)
.join(Image) .join(Image)
.join(Repository) .join(Repository)
.join(Namespace, on=(Namespace.id == Repository.namespace_user)) .join(Namespace, on=(Namespace.id == Repository.namespace_user))
.where(Repository.name == repo_name, Namespace.username == namespace)) .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): 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 """ 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): def get_repository_manifest(self, namespace_name, repository_name, digest):
try: 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: except model.DataModelException:
return None return None