You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2023/10/22 13:39:44 UTC

[buildstream-plugins] branch abderrahim/docker-rework created (now d4a6c99)

This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a change to branch abderrahim/docker-rework
in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git


      at d4a6c99  docker: support url in addition to registry-url/image

This branch includes the following new commits:

     new d4a6c99  docker: support url in addition to registry-url/image

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream-plugins] 01/01: docker: support url in addition to registry-url/image

Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a commit to branch abderrahim/docker-rework
in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git

commit d4a6c9980011de1e944e87ca61ebf99cc32681c1
Author: Abderrahim Kitouni <ab...@codethink.co.uk>
AuthorDate: Sun Oct 22 14:39:34 2023 +0100

    docker: support url in addition to registry-url/image
---
 src/buildstream_plugins/sources/docker.py | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/buildstream_plugins/sources/docker.py b/src/buildstream_plugins/sources/docker.py
index 45628fa..ede9431 100644
--- a/src/buildstream_plugins/sources/docker.py
+++ b/src/buildstream_plugins/sources/docker.py
@@ -356,13 +356,18 @@ class DockerSource(Source):
         )
 
         if "url" in node:
-            raise SourceError(
-                "{}: 'url' parameter is now deprecated, " "use 'registry-url' and 'image' instead.".format(self)
-            )
-
-        self.image = node.get_str("image")
-        self.original_registry_url = node.get_str("registry-url", _DOCKER_HUB_URL)
-        self.registry_url = self.translate_url(self.original_registry_url)
+            self.url = node.get_str("url")
+            translated_url = self.translate_url(self.url)
+            scheme, netloc, path, _, _ = urllib.parse.urlsplit(translated_url)
+            self.registry_url = urllib.parse.urlunsplit((scheme, netloc, '', '', ''))
+            self.image = path
+        elif "image" in node:
+            self.url = None
+            self.image = node.get_str("image")
+            self.original_registry_url = node.get_str("registry-url", _DOCKER_HUB_URL)
+            self.registry_url = self.translate_url(self.original_registry_url)
+        else:
+            raise SourceError("must define either url or image")
 
         if "ref" in node:
             self.digest = self._ref_to_digest(node.get_str("ref"))
@@ -384,7 +389,10 @@ class DockerSource(Source):
         return
 
     def get_unique_key(self):
-        return [self.original_registry_url, self.image, self.digest]
+        if self.url is not None:
+            return [self.url, self.digest]
+        else:
+            return [self.original_registry_url, self.image, self.digest]
 
     def get_ref(self):
         return None if self.digest is None else self._digest_to_ref(self.digest)