Files
Gitea/services/packages/pkgspec/manager.go
T
b0b31bc593 feat(packages): expose package file properties in the package files API (#40066)
Package files carry type specific properties like `debian.distribution`,
`debian.component`, `rpm.group` or `alpine.branch` that decide where a
file lives in a registry, but the API never returned them. A client
listing `GET /packages/{owner}/{type}/{name}/{version}/files` could not
tell which distribution or component a file belongs to, or tell apart
same-named files in different ones. Tools copying packages between
instances, like https://gitea.com/gitea/importer, need them to re-upload
a file to the same place.

This adds a `properties` map to `PackageFile`, limited to the properties
that locate a file. Internal ones like the rpm, alpine, arch and conda
metadata or the Debian control file stay hidden, as they can be many MiB
per file.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-29 18:10:36 +00:00

34 lines
1.2 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pkgspec
import (
packages_model "gitea.dev/models/packages"
packages_service "gitea.dev/services/packages"
"gitea.dev/services/packages/alpine"
"gitea.dev/services/packages/arch"
"gitea.dev/services/packages/conan"
"gitea.dev/services/packages/conda"
"gitea.dev/services/packages/debian"
"gitea.dev/services/packages/nuget"
"gitea.dev/services/packages/rpm"
"gitea.dev/services/packages/terraform"
"gitea.dev/services/packages/vagrant"
)
func InitManager() error {
mgr := packages_service.GetSpecManager()
mgr.Add(packages_model.TypeAlpine, &alpine.Specialization{})
mgr.Add(packages_model.TypeArch, &arch.Specialization{})
mgr.Add(packages_model.TypeConan, &conan.Specialization{})
mgr.Add(packages_model.TypeConda, &conda.Specialization{})
mgr.Add(packages_model.TypeDebian, &debian.Specialization{})
mgr.Add(packages_model.TypeNuGet, &nuget.Specialization{})
mgr.Add(packages_model.TypeRpm, &rpm.Specialization{})
mgr.Add(packages_model.TypeTerraformState, &terraform.Specialization{})
mgr.Add(packages_model.TypeVagrant, &vagrant.Specialization{})
// TODO: add more in the future, refactor the existing code to use this approach
return nil
}