feat(api/tag): generate manifest on revert_tag action
This commit is contained in:
parent
f7bf6a223c
commit
70508e3692
1 changed files with 12 additions and 5 deletions
|
@ -230,12 +230,8 @@ class RestoreTag(RepositoryParamResource):
|
||||||
# Restore the tag back to the previous image.
|
# Restore the tag back to the previous image.
|
||||||
image_id = request.get_json()['image']
|
image_id = request.get_json()['image']
|
||||||
manifest_digest = request.get_json().get('manifest_digest', None)
|
manifest_digest = request.get_json().get('manifest_digest', None)
|
||||||
if manifest_digest is not None:
|
|
||||||
existing_image = model.tag.restore_tag_to_manifest(repo, tag, manifest_digest)
|
|
||||||
else:
|
|
||||||
existing_image = model.tag.restore_tag_to_image(repo, tag, image_id)
|
|
||||||
|
|
||||||
# Log the reversion/restoration.
|
# Data for logging the reversion/restoration.
|
||||||
username = get_authenticated_user().username
|
username = get_authenticated_user().username
|
||||||
log_data = {
|
log_data = {
|
||||||
'username': username,
|
'username': username,
|
||||||
|
@ -244,6 +240,17 @@ class RestoreTag(RepositoryParamResource):
|
||||||
'image': image_id,
|
'image': image_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if manifest_digest is not None:
|
||||||
|
existing_image = model.tag.restore_tag_to_manifest(repo, tag, manifest_digest)
|
||||||
|
else:
|
||||||
|
existing_image = model.tag.restore_tag_to_image(repo, tag, image_id)
|
||||||
|
try:
|
||||||
|
_generate_and_store_manifest(namespace, repository, tag)
|
||||||
|
except:
|
||||||
|
# log and move on since we'll attempt to store manifest on first pull as well
|
||||||
|
logger.exception('unable to store manifest for tag', extra=log_data)
|
||||||
|
|
||||||
|
|
||||||
if existing_image is not None:
|
if existing_image is not None:
|
||||||
log_data['original_image'] = existing_image.docker_image_id
|
log_data['original_image'] = existing_image.docker_image_id
|
||||||
|
|
||||||
|
|
Reference in a new issue