fetch_from_docker_repo.py 950 B

12345678910111213141516171819202122232425262728293031323334
  1. import json
  2. import os
  3. import argparse
  4. import shutil
  5. def parse_args():
  6. parser = argparse.ArgumentParser()
  7. parser.add_argument('--link', required=True)
  8. parser.add_argument('--tag', required=True)
  9. parser.add_argument('--output-image-path', required=True)
  10. parser.add_argument('--output-info-path', required=True)
  11. parser.add_argument('--preloaded-path', required=True)
  12. return parser.parse_args()
  13. def main(args):
  14. # assume image was downloaded by runner
  15. assert os.path.exists(args.preloaded_path)
  16. output_dir = os.path.dirname(args.output_image_path)
  17. if not os.path.exists(output_dir):
  18. os.makedirs(output_dir)
  19. shutil.copyfile(args.preloaded_path, args.output_image_path)
  20. info = {
  21. 'link': args.link,
  22. 'tag': args.tag,
  23. }
  24. with open(args.output_info_path, 'w') as f:
  25. f.write(json.dumps(info))
  26. if __name__ == '__main__':
  27. args = parse_args()
  28. exit(main(args))