@@ -259,7 +259,10 @@ func (c *Client) StopContainer(containerID string, timeout int64) error {
259
259
ctx , cancel := getContextWithTimeout (ctxTimeout )
260
260
defer cancel ()
261
261
262
- _ , err = c .client .ContainerStop (ctx , & types.ContainerStopRequest {ContainerID : containerID , Timeout : timeout })
262
+ _ , err = c .client .ContainerStop (ctx , & types.ContainerStopRequest {
263
+ ContainerID : containerID ,
264
+ Timeout : timeout ,
265
+ })
263
266
264
267
return err
265
268
}
@@ -282,23 +285,38 @@ func (c *Client) GetImageInfo(image, tag string) (*types.ImageInfo, error) {
282
285
return nil , err
283
286
}
284
287
285
- // change `docker.io/library/imageName` to `imageName`
286
- if split := strings .Split (image , "/" ); len (split ) == 3 &&
287
- split [0 ] == defaultDomain &&
288
- split [1 ] == officialRepoName {
289
- image = split [2 ]
288
+ // kuberuntime relies on docker/distribution to parse image name to
289
+ // full image path and pass it to runtime.GetImageInfo():
290
+ // e.g.
291
+ // nginx -> docker.io/library/nginx
292
+ // alexellis/echo -> docker.io/alexellis/echo
293
+ //
294
+ // But hyper only returns alexellis/echo in imageList, so we
295
+ // need to fix the inconsistency here before doing filter.
296
+ split := strings .Split (image , "/" )
297
+ // 1. docker.io
298
+ if len (split ) == 3 && split [0 ] == defaultDomain {
299
+ // 2. docker.io/library
300
+ if split [1 ] == officialRepoName {
301
+ image = split [2 ]
302
+ } else {
303
+ // 3. docker.io/xxx
304
+ image = split [1 ] + "/" + split [2 ]
305
+ }
306
+
290
307
}
291
308
309
+ // filter images
292
310
fullImageName := fmt .Sprintf ("%s%s%s" , image , repoSep , tag )
293
- for _ , image := range imageList .ImageList {
294
- for _ , i := range image .RepoDigests {
311
+ for _ , hyperImage := range imageList .ImageList {
312
+ for _ , i := range hyperImage .RepoDigests {
295
313
if i == fullImageName {
296
- return image , nil
314
+ return hyperImage , nil
297
315
}
298
316
}
299
- for _ , i := range image .RepoTags {
317
+ for _ , i := range hyperImage .RepoTags {
300
318
if i == fullImageName {
301
- return image , nil
319
+ return hyperImage , nil
302
320
}
303
321
}
304
322
}
0 commit comments