in build-index/tagserver/server.go [382:428]
func (s *Server) listRepositoryHandler(w http.ResponseWriter, r *http.Request) error {
repo, err := httputil.ParseParam(r, "repo")
if err != nil {
return err
}
log.With("repository", repo).Debug("Listing repository tags")
client, err := s.backends.GetClient(repo)
if err != nil {
log.With("repository", repo).Errorf("Failed to get backend client for repository list: %s", err)
return handler.Errorf("backend manager: %s", err)
}
opts, err := buildPaginationOptions(r.URL)
if err != nil {
return err
}
result, err := client.List(path.Join(repo, "_manifests/tags"), opts...)
if err != nil {
log.With("repository", repo).Errorf("Failed to list repository tags from backend: %s", err)
return handler.Errorf("error listing from backend: %s", err)
}
var tags []string
for _, name := range result.Names {
// Strip repo prefix.
parts := strings.Split(name, ":")
if len(parts) != 2 {
log.With("repository", repo, "name", name).Warn("Skipping invalid tag name format")
continue
}
tags = append(tags, parts[1])
}
log.With("repository", repo, "tag_count", len(tags), "continuation_token", result.ContinuationToken).Debug("Successfully listed repository tags")
resp, err := buildPaginationResponse(r.URL, result.ContinuationToken, tags)
if err != nil {
return err
}
if err := json.NewEncoder(w).Encode(resp); err != nil {
return handler.Errorf("json encode: %s", err)
}
return nil
}