Make command optional in schema 2 manifests (as per OCI spec) and pull out additional information

Also updates the manifest view page to show the comment or digest if there is no command defined
This commit is contained in:
Joseph Schorr 2018-12-11 17:23:39 -05:00
parent fc691cefb4
commit 71b7a2b3a2
7 changed files with 53 additions and 16 deletions

View file

@ -37,10 +37,12 @@ def _label_dict(label):
def _layer_dict(manifest_layer, index):
# NOTE: The `command` in the layer is either a JSON string of an array (schema 1) or
# a single string (schema 2). The block below normalizes it to have the same format.
try:
command = json.loads(manifest_layer.command)
except (TypeError, ValueError):
command = [manifest_layer.command]
command = None
if manifest_layer.command:
try:
command = json.loads(manifest_layer.command)
except (TypeError, ValueError):
command = [manifest_layer.command]
return {
'index': index,
@ -48,6 +50,8 @@ def _layer_dict(manifest_layer, index):
'is_remote': manifest_layer.is_remote,
'urls': manifest_layer.urls,
'command': command,
'comment': manifest_layer.comment,
'author': manifest_layer.author,
'blob_digest': str(manifest_layer.blob_digest),
'created_datetime': format_date(manifest_layer.created_datetime),
}