summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-06-26 07:28:51 +0100
committerCédric Bosdonnat <cbosdonnat@suse.com>2017-06-28 13:59:36 +0200
commitbb5932eea5e0f9c32bb782ca70e2c9d0af0e0940 (patch)
tree4d602715cbf94961d834b2b8594c4856130296d7 /src
parentc5c66a84e0a38aa8c4daa5c458f626106c7a6768 (diff)
downloadvirt-bootstrap.git-bb5932eea5e0f9c32bb782ca70e2c9d0af0e0940.tar.gz
virt-bootstrap.git-bb5932eea5e0f9c32bb782ca70e2c9d0af0e0940.tar.xz
virt-bootstrap.git-bb5932eea5e0f9c32bb782ca70e2c9d0af0e0940.zip
Auto-correct docker source URI
Skopeo does not accept "docker:///" as valid URI format. [1] However, driver URIs within the Libvirt project and virtualization tools such as libvirt-sandbox use three slashes after URI scheme. [2] Make virt-bootstrap auto-correct the source URI for consistency with other tools. Following the syntax specifications in RFC 1808, "urlparse" recognizes a netloc only if it is properly introduced by ‘//’. [3] Otherwise the input is presumed to be a relative URL and thus to start with a path component. [4] - "self.image" is the path component - "self.registry" is the netloc component [1] https://github.com/projectatomic/skopeo/blob/master/docs/skopeo.1.md#skopeo-copy-1 [2] http://libvirt.org/uri.html [3] https://docs.python.org/2/library/urlparse.html [4] https://hg.python.org/cpython/file/2.7/Lib/urlparse.py#l187
Diffstat (limited to 'src')
-rw-r--r--src/virtBootstrap/sources.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/virtBootstrap/sources.py b/src/virtBootstrap/sources.py
index cef0623..650e45c 100644
--- a/src/virtBootstrap/sources.py
+++ b/src/virtBootstrap/sources.py
@@ -263,7 +263,9 @@ class DockerSource(object):
self.output_format = args.format
self.insecure = args.not_secure
self.no_cache = args.no_cache
- if self.image and not self.image.startswith('/'):
+ if not self.registry and self.image.startswith('/'):
+ self.image = self.image[1:]
+ elif self.image and not self.image.startswith('/'):
self.image = '/' + self.image
self.url = "docker://" + self.registry + self.image