// GetImageInfo gets the information of the image.
GetImageInfo gets the information of the image.
// GetImageInfo gets the information of the image .
func (c *Client) GetImageInfo(image, tag string) (*types.ImageInfo, error) {
	ctx, cancel := getContextWithTimeout(hyperContextTimeout)
	defer cancel()
	repoSep := ":"
	if strings.Index(tag, ":") > 0 {
		repoSep = "@"
	}
	req := types.ImageListRequest{
		Filter: image,
	}
	imageList, err := c.client.ImageList(ctx, &req)
	if err != nil {
		return nil, err
	}
	 But hyper only returns alexellis/echo in imageList, so we
	 need to fix the inconsistency here before doing filter.
	split := strings.Split(image, "/")
	 1. docker.io
	if len(split) == 3 && split[0] == defaultDomain {
		 2. docker.io/library
		if split[1] == officialRepoName {
			image = split[2]
		} else {
			 3. docker.io/xxx
			image = split[1] + "/" + split[2]
		}
	}
	 filter images
	fullImageName := fmt.Sprintf("%s%s%s", image, repoSep, tag)
	for _, hyperImage := range imageList.ImageList {
		for _, i := range hyperImage.RepoDigests {
			if i == fullImageName {
				return hyperImage, nil
			}
		}
		for _, i := range hyperImage.RepoTags {
			if i == fullImageName {
				return hyperImage, nil
			}
		}
	}
	return nil, fmt.Errorf("image %q with tag %q not found", image, tag)
}
func ( c * Client ) GetImageInfo ( image , tag string ) ( * types . ImageInfo , error ) { ctx , cancel := getContextWithTimeout ( hyperContextTimeout ) defer cancel ( ) repoSep := " " if strings . Index ( tag , " " ) > 0 { repoSep = " " } req := types . ImageListRequest { Filter : image , } imageList , err := c . client . ImageList ( ctx , & req ) if err != nil { return nil , err } split := strings . Split ( image , " " ) if len ( split ) == 3 && split [ 0 ] == defaultDomain { if split [ 1 ] == officialRepoName { image = split [ 2 ] } else { image = split [ 1 ] + " " + split [ 2 ] } } fullImageName := fmt . Sprintf ( " " , image , repoSep , tag ) for _ , hyperImage := range imageList . ImageList { for _ , i := range hyperImage . RepoDigests { if i == fullImageName { return hyperImage , nil } } for _ , i := range hyperImage . RepoTags { if i == fullImageName { return hyperImage , nil } } } return nil , fmt . Errorf ( " " , image , tag ) }
GetImageInfo gets the information of the image.
GetImageInfo gets the information of the image .
// check if tag is digest // kuberuntime relies on docker/distribution to parse image name to // full image path and pass it to runtime.GetImageInfo(): // e.g. // nginx -> docker.io/library/nginx // alexellis/echo  -> docker.io/alexellis/echo // // But hyper only returns alexellis/echo in imageList, so we // need to fix the inconsistency here before doing filter. // 1. docker.io // 2. docker.io/library // 3. docker.io/xxx // filter images