From 8b61b57c076fc6a4c712d2265b28daab9e5a1328 Mon Sep 17 00:00:00 2001 From: Daniel Sotirhos Date: Tue, 12 Mar 2024 10:43:20 -0700 Subject: [PATCH] Fix: Cannot locally test azul-docker-pycharm changes (#5986) --- src/azul/docker.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/azul/docker.py b/src/azul/docker.py index e3b8701b5a..2d0effc6db 100644 --- a/src/azul/docker.py +++ b/src/azul/docker.py @@ -89,6 +89,12 @@ def parse(cls, image_ref: str) -> Self: TagImageRef(registry='4', username='3', repository=('2',), tag='1') >>> ImageRef.parse('5/4/3/2:1') TagImageRef(registry='5', username='4', repository=('3', '2'), tag='1') + >>> ImageRef.parse('localhost:5000/docker.io/ucscgi/azul-pycharm:2023.3.4-15') + ... # doctest: +NORMALIZE_WHITESPACE + TagImageRef(registry='localhost:5000', + username='docker.io', + repository=('ucscgi', 'azul-pycharm'), + tag='2023.3.4-15') """ if '@' in image_ref: return DigestImageRef.parse(image_ref) @@ -215,7 +221,8 @@ class TagImageRef(ImageRef): @classmethod def parse(cls, image_ref: str) -> Self: - name, tag = image_ref.split(':') + # A colon in the first part of the name might separate host and port + name, _, tag = image_ref.rpartition(':') return cls.create(name, tag) @classmethod @@ -437,7 +444,10 @@ def get_blob(self, digest: str) -> bytes: @cached_property def _client(self): - return DXF(host=self.host, repo=self.name, auth=self._auth) + return DXF(host=self.host, + repo=self.name, + auth=self._auth, + insecure=self.host.startswith('localhost:') or self.host == 'localhost') def _auth(self, dxf: DXFBase, response: requests.Response): host: str = furl(response.request.url).host