summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources/docker_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-12-07 20:42:28 +0000
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-12-12 17:38:35 +0000
commit76a945f9f2b88407bac8f7a8cc0d1464db183f21 (patch)
treeda31cd76bb0149365269a65683e8da1db78b1806 /src/virtBootstrap/sources/docker_source.py
parentb38f588c76ad0541ae10fd2aa71677d5e19813d3 (diff)
downloadvirt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.tar.gz
virt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.tar.xz
virt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.zip
docker-source: Avoid skopeo copy in cache
The `skopeo copy` command has changed it's behaviour to keep only a files for single container image per directory. To get around this and keep cache of downloaded images is used temporary destination directory for 'skopeo copy' and image files are then moved in the cache folder.
Diffstat (limited to 'src/virtBootstrap/sources/docker_source.py')
-rw-r--r--src/virtBootstrap/sources/docker_source.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/virtBootstrap/sources/docker_source.py b/src/virtBootstrap/sources/docker_source.py
index a73fa64..ec1a812 100644
--- a/src/virtBootstrap/sources/docker_source.py
+++ b/src/virtBootstrap/sources/docker_source.py
@@ -137,10 +137,16 @@ class DockerSource(object):
"""
Download image layers using "skopeo copy".
"""
+
+ if self.no_cache:
+ dest_dir = self.images_dir
+ else:
+ dest_dir = utils.get_image_dir(no_cache=True)
+
# Note: we don't want to expose --src-cert-dir to users as
# they should place the certificates in the system
# folders for broader enablement
- skopeo_copy = ["skopeo", "copy", self.url, "dir:" + self.images_dir]
+ skopeo_copy = ["skopeo", "copy", self.url, "dir:" + dest_dir]
if self.insecure:
skopeo_copy.append('--src-tls-verify=false')
@@ -150,8 +156,12 @@ class DockerSource(object):
self.progress("Downloading container image", value=0, logger=logger)
# Run "skopeo copy" command
self.read_skopeo_progress(skopeo_copy)
- # Remove the manifest file as it is not needed
- os.remove(os.path.join(self.images_dir, "manifest.json"))
+
+ if not self.no_cache:
+ os.remove(os.path.join(dest_dir, "manifest.json"))
+ os.remove(os.path.join(dest_dir, "version"))
+ utils.copytree(dest_dir, self.images_dir)
+ shutil.rmtree(dest_dir)
def parse_output(self, proc):
"""