@@ -210,15 +210,18 @@ def diff_image(base_tag, target_tag):
210210 print_debug (f"Done. Load the output image archive { archive_name } in the offline (ddiff load { archive_name } )" )
211211 print_debug (f"{ archive_name } " )
212212
213- def load_image (image_tarball ):
213+ def load_image (base_tag , image_tarball ):
214214 input_dir = ".ddiff-image"
215215 shutil .rmtree (input_dir , ignore_errors = True )
216216 with tarfile .open (image_tarball ) as tar :
217217 tar .extractall ()
218218
219- with open (os .path .join (input_dir , "BASE" )) as f :
220- base_tag = f .read ().strip ()
221- base_repo = base_tag .split (":" )[0 ]
219+ # Parse base tag from the manifest onlyif not given
220+ if base_tag is None
221+ with open (os .path .join (input_dir , "BASE" )) as f :
222+ base_tag = f .read ().strip ()
223+ base_repo = base_tag .split (":" )[0 ]
224+
222225 with open (os .path .join (input_dir , "TARGET" )) as f :
223226 target_tag = f .read ().strip ()
224227 target_repo = target_tag .split (":" )[0 ]
@@ -321,10 +324,13 @@ def list_blobs(tag):
321324 sys .exit (1 )
322325 diff_image (args [0 ], args [1 ])
323326 elif command == "load" :
324- if len (args ) != 1 :
325- print ("Usage: python3 ddiff.py load <tar_file>" )
327+ if len (args ) > 2 :
328+ print ("Usage: python3 ddiff.py load <base tag> <tar_file> or python3 ddiff.py load < tar_file>" )
326329 sys .exit (1 )
327- load_image (args [0 ])
330+ elif len (args ) == 2 :
331+ load_image (args [0 ], args [1 ])
332+ elif len (args ) == 1 :
333+ load_image (None , args [0 ])
328334 elif command == "build" :
329335 if len (args ) < 1 :
330336 print ("Usage: python3 ddiff.py build <docker build args>" )
0 commit comments