feat(api/tag): generate manifest on revert_tag action

This commit is contained in:
EvB 2017-05-02 16:13:21 -04:00
parent f7bf6a223c
commit 70508e3692

View file

@ -230,12 +230,8 @@ class RestoreTag(RepositoryParamResource):
# Restore the tag back to the previous image.
image_id = request.get_json()['image']
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
log_data = {
'username': username,
@ -244,6 +240,17 @@ class RestoreTag(RepositoryParamResource):
'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:
log_data['original_image'] = existing_image.docker_image_id