summaryrefslogtreecommitdiff
path: root/test/python/docker/__init__.py
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-13 15:00:01 +0100
committerGitHub <noreply@github.com>2020-11-13 15:00:01 +0100
commit0b1a60ec27928a40ac827148c1517098612616bd (patch)
treeb3902b4614cb521c9873d3200d7f073a135d6308 /test/python/docker/__init__.py
parent0b3f789a08787c3b2d832a405f6d2d6ff90f5720 (diff)
parenta1187ee6f3a85f8d4e68717731b7b9e2163e8f25 (diff)
downloadpodman-0b1a60ec27928a40ac827148c1517098612616bd.tar.gz
podman-0b1a60ec27928a40ac827148c1517098612616bd.tar.bz2
podman-0b1a60ec27928a40ac827148c1517098612616bd.zip
Merge pull request #8308 from jwhonce/jira/run-976
Refactor to use DockerClient vs APIClient
Diffstat (limited to 'test/python/docker/__init__.py')
-rw-r--r--test/python/docker/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py
index 0e10676b9..316b102f4 100644
--- a/test/python/docker/__init__.py
+++ b/test/python/docker/__init__.py
@@ -6,6 +6,8 @@ import shutil
import subprocess
import tempfile
+from docker import DockerClient
+
from test.python.docker import constant
@@ -141,16 +143,15 @@ class Podman(object):
def tear_down(self):
shutil.rmtree(self.anchor_directory, ignore_errors=True)
- def restore_image_from_cache(self, client):
- img = os.path.join(self.image_cache, constant.ALPINE_TARBALL)
- if not os.path.exists(img):
- client.pull(constant.ALPINE)
- image = client.get_image(constant.ALPINE)
- with open(img, mode="wb") as tarball:
- for frame in image:
+ def restore_image_from_cache(self, client: DockerClient):
+ path = os.path.join(self.image_cache, constant.ALPINE_TARBALL)
+ if not os.path.exists(path):
+ img = client.images.pull(constant.ALPINE)
+ with open(path, mode="wb") as tarball:
+ for frame in img.save(named=True):
tarball.write(frame)
else:
- self.run("load", "-i", img, check=True)
+ self.run("load", "-i", path, check=True)
def flush_image_cache(self):
for f in pathlib.Path(self.image_cache).glob("*.tar"):