mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-29 04:06:58 +00:00
make sure we return annotations on multi-arch manifests
This commit is contained in:
@@ -310,17 +310,39 @@ func GetUserRepositories(db *sql.DB, did string) ([]Repository, error) {
|
||||
}
|
||||
|
||||
// GetRepositoryMetadata retrieves metadata for a repository from its most recent manifest
|
||||
// Prioritizes manifests with non-empty metadata fields
|
||||
func GetRepositoryMetadata(db *sql.DB, did string, repository string) (title, description, sourceURL, documentationURL, licenses, iconURL, readmeURL string, err error) {
|
||||
var titleNull, descriptionNull, sourceURLNull, documentationURLNull, licensesNull, iconURLNull, readmeURLNull sql.NullString
|
||||
|
||||
// Try to find a manifest with metadata first (prefer manifests with any non-empty annotation field)
|
||||
err = db.QueryRow(`
|
||||
SELECT title, description, source_url, documentation_url, licenses, icon_url, readme_url
|
||||
FROM manifests
|
||||
WHERE did = ? AND repository = ?
|
||||
AND (
|
||||
(title IS NOT NULL AND title != '')
|
||||
OR (description IS NOT NULL AND description != '')
|
||||
OR (source_url IS NOT NULL AND source_url != '')
|
||||
OR (documentation_url IS NOT NULL AND documentation_url != '')
|
||||
OR (licenses IS NOT NULL AND licenses != '')
|
||||
OR (icon_url IS NOT NULL AND icon_url != '')
|
||||
OR (readme_url IS NOT NULL AND readme_url != '')
|
||||
)
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 1
|
||||
`, did, repository).Scan(&titleNull, &descriptionNull, &sourceURLNull, &documentationURLNull, &licensesNull, &iconURLNull, &readmeURLNull)
|
||||
|
||||
// If no manifest with metadata found, fall back to latest manifest (any type)
|
||||
if err == sql.ErrNoRows {
|
||||
err = db.QueryRow(`
|
||||
SELECT title, description, source_url, documentation_url, licenses, icon_url, readme_url
|
||||
FROM manifests
|
||||
WHERE did = ? AND repository = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 1
|
||||
`, did, repository).Scan(&titleNull, &descriptionNull, &sourceURLNull, &documentationURLNull, &licensesNull, &iconURLNull, &readmeURLNull)
|
||||
}
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
// No manifests found - return empty strings
|
||||
return "", "", "", "", "", "", "", nil
|
||||
|
||||
Reference in New Issue
Block a user