Example #1
0
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 ""
}