From bb5932eea5e0f9c32bb782ca70e2c9d0af0e0940 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Mon, 26 Jun 2017 07:28:51 +0100 Subject: Auto-correct docker source URI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/virtBootstrap/sources.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/virtBootstrap/sources.py') 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 -- cgit