Skip to content

Commit 3bdbd08

Browse files
author
Nisha K
committed
formats: Modify layer title based on manifest
This is work towards #948 The html formatting of lists allows for an expansion UI under the title of the layer object. The title is the layer tarball's digest. In the Docker image layout, this can be directly taken from the "tar_file" key. But in the OCI layout, this value is taken from the "digest" key. This commit allows for that difference and defaults to the layer's index if neither one of those keys exist. Signed-off-by: Nisha K <[email protected]>
1 parent 3a0ac50 commit 3bdbd08

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tern/formats/html/generator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,20 @@ def manifest_handler(list_obj, indent):
148148

149149

150150
def layers_handler(list_obj, indent):
151-
'''Write html code for the origins list in the report
151+
'''Write html code for the layers list in the report
152152
with tar_file hash as title'''
153153
html_string = ' '*indent + '<ul class ="nested"> \n'
154154
for lo in list_obj:
155+
# check whether the item is a dictionary that contains the "tar_file"
156+
# property or not
157+
if "tar_file" in lo:
158+
title = str(lo["tar_file"][:10])
159+
elif "digest" in lo:
160+
title = str(lo["digest"][:10])
161+
else:
162+
title = list_obj.index(lo)
155163
html_string = html_string + ' '*indent + '<li><span class="caret">' \
156-
+ str(lo["tar_file"][:10]) + ' : ' + '</span> \n '
164+
+ title + ' : ' + '</span> \n '
157165
html_string = html_string + dict_handler(lo, indent+1)
158166
html_string = html_string + ' '*indent + '</li> \n'
159167
html_string = html_string + ' '*indent + '</ul> \n'

0 commit comments

Comments
 (0)