func lookupID(s *graph.TagStore, name string) string { s.Lock() defer s.Unlock() repo, tag := parsers.ParseRepositoryTag(name) if r, exists := s.Repositories[repo]; exists { if tag == "" { tag = "latest" } if id, exists := r[tag]; exists { return id } } if r, exists := s.Repositories[registry.IndexName+"/"+repo]; exists { if tag == "" { tag = "latest" } if id, exists := r[tag]; exists { return id } } names := strings.Split(name, "/") if len(names) > 1 { if r, exists := s.Repositories[strings.Join(names[1:], "/")]; exists { if tag == "" { tag = "latest" } if id, exists := r[tag]; exists { return id } } } return "" }
func lookupImage(s *graph.TagStore, name string) (*image.Image, error) { img, err := s.LookupImage(name) if img != nil { return img, err } id := lookupID(s, name) if id != "" { return s.LookupImage(id) } return nil, err }
func lookup(s *graph.TagStore, name string) (*types.ImageInspect, error) { img, err := s.Lookup(name) if img != nil { return img, err } id := lookupID(s, name) if id != "" { return s.Lookup(id) } return nil, err }
func getImage(s *graph.TagStore, img, imgID string) (string, error) { // both Image and ImageID is actually ids, nothing to guess if strings.HasPrefix(imgID, img) { return img, nil } id, err := s.GetID(img) if err != nil { if err == graph.ErrNameIsNotExist { return imgID, nil } return "", err } if id != imgID { return imgID, nil } return img, nil }