(
client, source_dir: pathlib.Path, image_dir: pathlib.Path, name, host_platform
)
| 69 | |
| 70 | |
| 71 | def get_image( |
| 72 | client, source_dir: pathlib.Path, image_dir: pathlib.Path, name, host_platform |
| 73 | ): |
| 74 | if client is None: |
| 75 | return None |
| 76 | |
| 77 | image_name = f"image-{name}.{host_platform}" |
| 78 | image_path = image_dir / image_name |
| 79 | tar_path = image_path.with_suffix(".tar") |
| 80 | |
| 81 | with image_path.open("r") as fh: |
| 82 | image_id = fh.read().strip() |
| 83 | |
| 84 | try: |
| 85 | client.images.get(image_id) |
| 86 | return image_id |
| 87 | except docker.errors.ImageNotFound: |
| 88 | if tar_path.exists(): |
| 89 | with tar_path.open("rb") as fh: |
| 90 | data = fh.read() |
| 91 | client.images.load(data) |
| 92 | |
| 93 | return image_id |
| 94 | |
| 95 | else: |
| 96 | return build_docker_image( |
| 97 | client, str(source_dir).encode(), image_dir, name, host_platform |
| 98 | ) |
| 99 | |
| 100 | |
| 101 | def copy_file_to_container(path, container, container_path, archive_path=None): |
no test coverage detected