Code review fixes

This commit is contained in:
Joseph Schorr 2018-11-14 09:15:58 +02:00
parent 3b4002877a
commit d97055e2ba
6 changed files with 30 additions and 15 deletions

View file

@ -95,8 +95,13 @@ def _create_manifest(repository_id, manifest_interface_instance, storage):
logger.exception('Could not load manifest labels for child manifest')
return None
# Get/create the child manifest in the database.
# NOTE: Content type restrictions in manifest lists ensure that the child manifests
# must be image manifests, as opposed to lists themselves. We put this check here to
# be extra careful in ensuring we don't create empty manifests. If this reality changes,
# should remove this check.
assert list(child_manifest.layers)
# Get/create the child manifest in the database.
child_manifest_info = get_or_create_manifest(repository_id, child_manifest, storage)
if child_manifest_info is None:
logger.error('Could not get/create child manifest')
@ -166,8 +171,10 @@ def _create_manifest(repository_id, manifest_interface_instance, storage):
media_type = 'application/json' if is_json(value) else 'text/plain'
create_manifest_label(manifest, key, value, 'manifest', media_type)
# Return the dictionary of labels to apply. We only return those labels either defined on
# the manifest or shared amongst all the child manifest.
# Return the dictionary of labels to apply (i.e. those labels that cause an action to be taken
# on the manifest or its resulting tags). We only return those labels either defined on
# the manifest or shared amongst all the child manifests. We intersect amongst all child manifests
# to ensure that any action performed is defined in all manifests.
labels_to_apply = labels or {}
if child_manifest_label_dicts:
labels_to_apply = child_manifest_label_dicts[0].viewitems()