@@ -185,8 +185,28 @@ def _default_password(self):
185
185
base64 .b64decode (b64_auth .encode ("utf-8" )).decode ("utf-8" ).split (":" , 1 )[1 ]
186
186
)
187
187
188
- async def get_image_manifest (self , image , tag ):
188
+ @staticmethod
189
+ def parse_image_name (name ):
190
+ """Parse a docker image string into (registry, image, tag)"""
191
+ # name could be "localhost:5000/foo:tag"
192
+ # or "gcr.io/project/subrepo/sub/sub/sub:tag"
193
+ # or "org/repo:tag" for implicit docker.io
194
+ registry , _ , tagged_image = name .partition ("/" )
195
+ if tagged_image and (registry == "localhost" or any (c in registry for c in ("." , ":" ))):
196
+ # registry host is specified
197
+ pass
198
+ else :
199
+ # registry not given, use implicit default docker.io registry
200
+ registry = "docker.io"
201
+ tagged_image = name
202
+ image , _ , tag = tagged_image .partition (":" )
203
+
204
+ return registry , image , tag
205
+
206
+ async def get_image_manifest (self , name ):
189
207
client = httpclient .AsyncHTTPClient ()
208
+ _ , image , tag = DockerRegistry .parse_image_name (name )
209
+
190
210
url = "{}/v2/{}/manifests/{}" .format (self .url , image , tag )
191
211
# first, get a token to perform the manifest request
192
212
if self .token_url :
0 commit comments