Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error)
- func CountVersions(ctx context.Context, opts *PackageSearchOptions) (int64, error)
- func DeleteAllProperties(ctx context.Context, refType PropertyType, refID int64) error
- func DeleteBlobByID(ctx context.Context, blobID int64) error
- func DeleteBlobUploadByID(ctx context.Context, id string) error
- func DeleteCleanupRuleByID(ctx context.Context, ruleID int64) error
- func DeleteFileByID(ctx context.Context, fileID int64) error
- func DeletePackageByID(ctx context.Context, packageID int64) error
- func DeletePropertyByID(ctx context.Context, propertyID int64) error
- func DeletePropertyByName(ctx context.Context, refType PropertyType, refID int64, name string) error
- func DeleteVersionByID(ctx context.Context, versionID int64) error
- func ExistPackageBlobWithSHA(ctx context.Context, blobSha256 string) (bool, error)
- func ExistVersion(ctx context.Context, opts *PackageSearchOptions) (bool, error)
- func GetDistinctPropertyValues(ctx context.Context, packageType Type, ownerID int64, refType PropertyType, ...) ([]string, error)
- func GetTotalBlobSize(ctx context.Context) (int64, error)
- func GetTotalUnreferencedBlobSize(ctx context.Context) (int64, error)
- func HasOwnerCleanupRuleForPackageType(ctx context.Context, ownerID int64, packageType Type) (bool, error)
- func HasOwnerPackages(ctx context.Context, ownerID int64) (bool, error)
- func HasRepositoryPackages(ctx context.Context, repositoryID int64) (bool, error)
- func HasVersionFileReferences(ctx context.Context, versionID int64) (bool, error)
- func IncrementDownloadCounter(ctx context.Context, versionID int64) error
- func IsBlobAccessibleForUser(ctx context.Context, blobID int64, user *user_model.User) (bool, error)
- func IterateEnabledCleanupRules(ctx context.Context, callback func(context.Context, *PackageCleanupRule) error) error
- func SetRepositoryLink(ctx context.Context, packageID, repoID int64) error
- func UnlinkRepositoryFromAllPackages(ctx context.Context, repoID int64) error
- func UpdateBlobUpload(ctx context.Context, pbu *PackageBlobUpload) error
- func UpdateCleanupRule(ctx context.Context, pcr *PackageCleanupRule) error
- func UpdateProperty(ctx context.Context, pp *PackageProperty) error
- func UpdateVersion(ctx context.Context, pv *PackageVersion) error
- type DistinctPropertyDependency
- type Package
- func FindUnreferencedPackages(ctx context.Context) ([]*Package, error)
- func GetPackageByID(ctx context.Context, packageID int64) (*Package, error)
- func GetPackageByName(ctx context.Context, ownerID int64, packageType Type, name string) (*Package, error)
- func GetPackagesByType(ctx context.Context, ownerID int64, packageType Type) ([]*Package, error)
- func TryInsertPackage(ctx context.Context, p *Package) (*Package, error)
- type PackageBlob
- type PackageBlobUpload
- type PackageCleanupRule
- type PackageDescriptor
- type PackageFile
- func GetFileForVersionByID(ctx context.Context, versionID, fileID int64) (*PackageFile, error)
- func GetFileForVersionByName(ctx context.Context, versionID int64, name, key string) (*PackageFile, error)
- func GetFilesByVersionID(ctx context.Context, versionID int64) ([]*PackageFile, error)
- func SearchFiles(ctx context.Context, opts *PackageFileSearchOptions) ([]*PackageFile, int64, error)
- func TryInsertFile(ctx context.Context, pf *PackageFile) (*PackageFile, error)
- type PackageFileDescriptor
- type PackageFileSearchOptions
- type PackageProperty
- func GetProperties(ctx context.Context, refType PropertyType, refID int64) ([]*PackageProperty, error)
- func GetPropertiesByName(ctx context.Context, refType PropertyType, refID int64, name string) ([]*PackageProperty, error)
- func InsertProperty(ctx context.Context, refType PropertyType, refID int64, name, value string) (*PackageProperty, error)
- type PackagePropertyList
- type PackageSearchOptions
- type PackageVersion
- func GetInternalVersionByNameAndVersion(ctx context.Context, ownerID int64, packageType Type, name, version string) (*PackageVersion, error)
- func GetOrInsertVersion(ctx context.Context, pv *PackageVersion) (*PackageVersion, error)
- func GetVersionByID(ctx context.Context, versionID int64) (*PackageVersion, error)
- func GetVersionByNameAndVersion(ctx context.Context, ownerID int64, packageType Type, name, version string) (*PackageVersion, error)
- func GetVersionsByPackageName(ctx context.Context, ownerID int64, packageType Type, name string) ([]*PackageVersion, error)
- func GetVersionsByPackageType(ctx context.Context, ownerID int64, packageType Type) ([]*PackageVersion, error)
- func SearchLatestVersions(ctx context.Context, opts *PackageSearchOptions) ([]*PackageVersion, int64, error)
- func SearchVersions(ctx context.Context, opts *PackageSearchOptions) ([]*PackageVersion, int64, error)
- type PropertyType
- type SearchValue
- type Type
- type VersionSort
Constants ¶
const EmptyFileKey = ""
EmptyFileKey is a named constant for an empty file key
Variables ¶
var ( // ErrDuplicatePackage indicates a duplicated package error ErrDuplicatePackage = util.NewAlreadyExistErrorf("package already exists") // ErrPackageNotExist indicates a package not exist error ErrPackageNotExist = util.NewNotExistErrorf("package does not exist") )
var ( // ErrDuplicatePackageFile indicates a duplicated package file error ErrDuplicatePackageFile = util.NewAlreadyExistErrorf("package file already exists") // ErrPackageFileNotExist indicates a package file not exist error ErrPackageFileNotExist = util.NewNotExistErrorf("package file does not exist") )
var ErrDuplicatePackageVersion = util.NewAlreadyExistErrorf("package version already exists")
ErrDuplicatePackageVersion indicates a duplicated package version error
var ErrPackageBlobNotExist = util.NewNotExistErrorf("package blob does not exist")
ErrPackageBlobNotExist indicates a package blob not exist error
var ErrPackageBlobUploadNotExist = util.NewNotExistErrorf("package blob upload does not exist")
ErrPackageBlobUploadNotExist indicates a package blob upload not exist error
var ErrPackageCleanupRuleNotExist = util.NewNotExistErrorf("package blob does not exist")
var TypeList = []Type{ TypeAlpine, TypeCargo, TypeChef, TypeComposer, TypeConan, TypeConda, TypeContainer, TypeCran, TypeDebian, TypeGeneric, TypeGo, TypeHelm, TypeMaven, TypeNpm, TypeNuGet, TypePub, TypePyPI, TypeRpm, TypeRubyGems, TypeSwift, TypeVagrant, }
Functions ¶
func CalculateFileSize ¶
func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error)
CalculateFileSize sums up all blob sizes matching the search options. It does NOT respect the deduplication of blobs.
func CountVersions ¶
func CountVersions(ctx context.Context, opts *PackageSearchOptions) (int64, error)
CountVersions counts all versions of packages matching the search options
func DeleteAllProperties ¶
func DeleteAllProperties(ctx context.Context, refType PropertyType, refID int64) error
DeleteAllProperties deletes all properties of a ref
func DeleteBlobByID ¶
DeleteBlobByID deletes a blob by id
func DeleteBlobUploadByID ¶
DeleteBlobUploadByID deletes the blob upload
func DeleteFileByID ¶
DeleteFileByID deletes a file
func DeletePackageByID ¶
DeletePackageByID deletes a package by id
func DeletePropertyByID ¶
DeletePropertyByID deletes a property
func DeletePropertyByName ¶
func DeletePropertyByName(ctx context.Context, refType PropertyType, refID int64, name string) error
DeletePropertyByName deletes properties by name
func DeleteVersionByID ¶
DeleteVersionByID deletes a version by id
func ExistPackageBlobWithSHA ¶
ExistPackageBlobWithSHA returns if a package blob exists with the provided sha
func ExistVersion ¶
func ExistVersion(ctx context.Context, opts *PackageSearchOptions) (bool, error)
ExistVersion checks if a version matching the search options exist
func GetDistinctPropertyValues ¶
func GetDistinctPropertyValues(ctx context.Context, packageType Type, ownerID int64, refType PropertyType, propertyName string, dep *DistinctPropertyDependency) ([]string, error)
GetDistinctPropertyValues returns all distinct property values for a given type. Optional: Search only in dependence of another property.
func GetTotalBlobSize ¶
GetTotalBlobSize returns the total blobs size in bytes
func GetTotalUnreferencedBlobSize ¶
GetTotalUnreferencedBlobSize returns the total size of all unreferenced blobs in bytes
func HasOwnerPackages ¶
HasOwnerPackages tests if a user/org has accessible packages
func HasRepositoryPackages ¶
HasRepositoryPackages tests if a repository has packages
func HasVersionFileReferences ¶
HasVersionFileReferences checks if there are associated files
func IncrementDownloadCounter ¶
IncrementDownloadCounter increments the download counter of a version
func IsBlobAccessibleForUser ¶
func IsBlobAccessibleForUser(ctx context.Context, blobID int64, user *user_model.User) (bool, error)
IsBlobAccessibleForUser tests if the user has access to the blob
func SetRepositoryLink ¶
SetRepositoryLink sets the linked repository
func UnlinkRepositoryFromAllPackages ¶
UnlinkRepositoryFromAllPackages unlinks every package from the repository
func UpdateBlobUpload ¶
func UpdateBlobUpload(ctx context.Context, pbu *PackageBlobUpload) error
UpdateBlobUpload updates the blob upload
func UpdateCleanupRule ¶
func UpdateCleanupRule(ctx context.Context, pcr *PackageCleanupRule) error
func UpdateProperty ¶
func UpdateProperty(ctx context.Context, pp *PackageProperty) error
UpdateProperty updates a property
func UpdateVersion ¶
func UpdateVersion(ctx context.Context, pv *PackageVersion) error
UpdateVersion updates a version
Types ¶
type Package ¶
type Package struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` RepoID int64 `xorm:"INDEX"` Type Type `xorm:"UNIQUE(s) INDEX NOT NULL"` Name string `xorm:"NOT NULL"` LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` SemverCompatible bool `xorm:"NOT NULL DEFAULT false"` IsInternal bool `xorm:"NOT NULL DEFAULT false"` }
Package represents a package
func FindUnreferencedPackages ¶
FindUnreferencedPackages gets all packages without associated versions
func GetPackageByID ¶
GetPackageByID gets a package by id
func GetPackageByName ¶
func GetPackageByName(ctx context.Context, ownerID int64, packageType Type, name string) (*Package, error)
GetPackageByName gets a package by name
func GetPackagesByType ¶
GetPackagesByType gets all packages of a specific type
type PackageBlob ¶
type PackageBlob struct { ID int64 `xorm:"pk autoincr"` Size int64 `xorm:"NOT NULL DEFAULT 0"` HashMD5 string `xorm:"hash_md5 char(32) UNIQUE(md5) INDEX NOT NULL"` HashSHA1 string `xorm:"hash_sha1 char(40) UNIQUE(sha1) INDEX NOT NULL"` HashSHA256 string `xorm:"hash_sha256 char(64) UNIQUE(sha256) INDEX NOT NULL"` HashSHA512 string `xorm:"hash_sha512 char(128) UNIQUE(sha512) INDEX NOT NULL"` CreatedUnix timeutil.TimeStamp `xorm:"created INDEX NOT NULL"` }
PackageBlob represents a package blob
func FindExpiredUnreferencedBlobs ¶
func FindExpiredUnreferencedBlobs(ctx context.Context, olderThan time.Duration) ([]*PackageBlob, error)
FindExpiredUnreferencedBlobs gets all blobs without associated files older than the specific duration
func GetBlobByID ¶
func GetBlobByID(ctx context.Context, blobID int64) (*PackageBlob, error)
GetBlobByID gets a blob by id
func GetOrInsertBlob ¶
func GetOrInsertBlob(ctx context.Context, pb *PackageBlob) (*PackageBlob, bool, error)
GetOrInsertBlob inserts a blob. If the blob exists already the existing blob is returned
type PackageBlobUpload ¶
type PackageBlobUpload struct { ID string `xorm:"pk"` BytesReceived int64 `xorm:"NOT NULL DEFAULT 0"` HashStateBytes []byte `xorm:"BLOB"` CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL"` UpdatedUnix timeutil.TimeStamp `xorm:"updated INDEX NOT NULL"` }
PackageBlobUpload represents a package blob upload
func CreateBlobUpload ¶
func CreateBlobUpload(ctx context.Context) (*PackageBlobUpload, error)
CreateBlobUpload inserts a blob upload
func FindExpiredBlobUploads ¶
func FindExpiredBlobUploads(ctx context.Context, olderThan time.Duration) ([]*PackageBlobUpload, error)
FindExpiredBlobUploads gets all expired blob uploads
func GetBlobUploadByID ¶
func GetBlobUploadByID(ctx context.Context, id string) (*PackageBlobUpload, error)
GetBlobUploadByID gets a blob upload by id
type PackageCleanupRule ¶
type PackageCleanupRule struct { ID int64 `xorm:"pk autoincr"` Enabled bool `xorm:"INDEX NOT NULL DEFAULT false"` OwnerID int64 `xorm:"UNIQUE(s) INDEX NOT NULL DEFAULT 0"` Type Type `xorm:"UNIQUE(s) INDEX NOT NULL"` KeepCount int `xorm:"NOT NULL DEFAULT 0"` KeepPattern string `xorm:"NOT NULL DEFAULT ''"` KeepPatternMatcher *regexp.Regexp `xorm:"-"` RemoveDays int `xorm:"NOT NULL DEFAULT 0"` RemovePattern string `xorm:"NOT NULL DEFAULT ''"` RemovePatternMatcher *regexp.Regexp `xorm:"-"` MatchFullName bool `xorm:"NOT NULL DEFAULT false"` CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL DEFAULT 0"` UpdatedUnix timeutil.TimeStamp `xorm:"updated NOT NULL DEFAULT 0"` }
PackageCleanupRule represents a rule which describes when to clean up package versions
func GetCleanupRuleByID ¶
func GetCleanupRuleByID(ctx context.Context, id int64) (*PackageCleanupRule, error)
func GetCleanupRulesByOwner ¶
func GetCleanupRulesByOwner(ctx context.Context, ownerID int64) ([]*PackageCleanupRule, error)
func InsertCleanupRule ¶
func InsertCleanupRule(ctx context.Context, pcr *PackageCleanupRule) (*PackageCleanupRule, error)
func (*PackageCleanupRule) CompiledPattern ¶
func (pcr *PackageCleanupRule) CompiledPattern() error
type PackageDescriptor ¶
type PackageDescriptor struct { Package *Package //Owner *user_model.User Repository *repo_model.Repository Version *PackageVersion SemVer *version.Version //Creator *user_model.User PackageProperties PackagePropertyList VersionProperties PackagePropertyList Metadata any Files []*PackageFileDescriptor }
PackageDescriptor describes a package
func GetPackageDescriptor ¶
func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDescriptor, error)
GetPackageDescriptor gets the package description for a version
func GetPackageDescriptors ¶
func GetPackageDescriptors(ctx context.Context, pvs []*PackageVersion) ([]*PackageDescriptor, error)
GetPackageDescriptors gets the package descriptions for the versions
func (*PackageDescriptor) CalculateBlobSize ¶
func (pd *PackageDescriptor) CalculateBlobSize() int64
CalculateBlobSize returns the total blobs size in bytes
func (*PackageDescriptor) FullWebLink ¶
func (pd *PackageDescriptor) FullWebLink() string
FullWebLink returns the package version web link
func (*PackageDescriptor) PackageWebLink ¶
func (pd *PackageDescriptor) PackageWebLink() string
PackageWebLink returns the package web link
type PackageFile ¶
type PackageFile struct { ID int64 `xorm:"pk autoincr"` VersionID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` BlobID int64 `xorm:"INDEX NOT NULL"` Name string `xorm:"NOT NULL"` LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` CompositeKey string `xorm:"UNIQUE(s) INDEX"` IsLead bool `xorm:"NOT NULL DEFAULT false"` CreatedUnix timeutil.TimeStamp `xorm:"created INDEX NOT NULL"` }
PackageFile represents a package file
func GetFileForVersionByID ¶
func GetFileForVersionByID(ctx context.Context, versionID, fileID int64) (*PackageFile, error)
GetFileForVersionByID gets a file of a version by id
func GetFileForVersionByName ¶
func GetFileForVersionByName(ctx context.Context, versionID int64, name, key string) (*PackageFile, error)
GetFileForVersionByName gets a file of a version by name
func GetFilesByVersionID ¶
func GetFilesByVersionID(ctx context.Context, versionID int64) ([]*PackageFile, error)
GetFilesByVersionID gets all files of a version
func SearchFiles ¶
func SearchFiles(ctx context.Context, opts *PackageFileSearchOptions) ([]*PackageFile, int64, error)
SearchFiles gets all files of packages matching the search options
func TryInsertFile ¶
func TryInsertFile(ctx context.Context, pf *PackageFile) (*PackageFile, error)
TryInsertFile inserts a file. If the file exists already ErrDuplicatePackageFile is returned
type PackageFileDescriptor ¶
type PackageFileDescriptor struct { File *PackageFile Blob *PackageBlob Properties PackagePropertyList }
PackageFileDescriptor describes a package file
func GetPackageFileDescriptor ¶
func GetPackageFileDescriptor(ctx context.Context, pf *PackageFile) (*PackageFileDescriptor, error)
GetPackageFileDescriptor gets a package file descriptor for a package file
func GetPackageFileDescriptors ¶
func GetPackageFileDescriptors(ctx context.Context, pfs []*PackageFile) ([]*PackageFileDescriptor, error)
GetPackageFileDescriptors gets the package file descriptors for the package files
type PackageFileSearchOptions ¶
type PackageFileSearchOptions struct { OwnerID int64 PackageType Type VersionID int64 Query string CompositeKey string Properties map[string]string OlderThan time.Duration HashAlgorithm string Hash string db.Paginator }
PackageFileSearchOptions are options for SearchXXX methods
type PackageProperty ¶
type PackageProperty struct { ID int64 `xorm:"pk autoincr"` RefType PropertyType `xorm:"INDEX NOT NULL"` RefID int64 `xorm:"INDEX NOT NULL"` Name string `xorm:"INDEX NOT NULL"` Value string `xorm:"TEXT NOT NULL"` }
PackageProperty represents a property of a package, version or file
func GetProperties ¶
func GetProperties(ctx context.Context, refType PropertyType, refID int64) ([]*PackageProperty, error)
GetProperties gets all properties
func GetPropertiesByName ¶
func GetPropertiesByName(ctx context.Context, refType PropertyType, refID int64, name string) ([]*PackageProperty, error)
GetPropertiesByName gets all properties with a specific name
func InsertProperty ¶
func InsertProperty(ctx context.Context, refType PropertyType, refID int64, name, value string) (*PackageProperty, error)
InsertProperty creates a property
type PackagePropertyList ¶
type PackagePropertyList []*PackageProperty
PackagePropertyList is a list of package properties
func (PackagePropertyList) GetByName ¶
func (l PackagePropertyList) GetByName(name string) string
GetByName gets the first property value with the specific name
type PackageSearchOptions ¶
type PackageSearchOptions struct { OwnerID int64 RepoID int64 Type Type PackageID int64 Name SearchValue // only results with the specific name are found Version SearchValue // only results with the specific version are found Properties map[string]string // only results are found which contain all listed version properties with the specific value IsInternal util.OptionalBool HasFileWithName string // only results are found which are associated with a file with the specific name HasFiles util.OptionalBool // only results are found which have associated files Sort VersionSort db.Paginator }
PackageSearchOptions are options for SearchXXX methods All fields optional and are not used if they have their default value (nil, "", 0)
func (*PackageSearchOptions) ToConds ¶
func (opts *PackageSearchOptions) ToConds() builder.Cond
type PackageVersion ¶
type PackageVersion struct { ID int64 `xorm:"pk autoincr"` PackageID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` CreatorID int64 `xorm:"NOT NULL DEFAULT 0"` Version string `xorm:"NOT NULL"` LowerVersion string `xorm:"UNIQUE(s) INDEX NOT NULL"` CreatedUnix timeutil.TimeStamp `xorm:"created INDEX NOT NULL"` IsInternal bool `xorm:"INDEX NOT NULL DEFAULT false"` MetadataJSON string `xorm:"metadata_json LONGTEXT"` DownloadCount int64 `xorm:"NOT NULL DEFAULT 0"` }
PackageVersion represents a package version
func GetInternalVersionByNameAndVersion ¶
func GetInternalVersionByNameAndVersion(ctx context.Context, ownerID int64, packageType Type, name, version string) (*PackageVersion, error)
GetInternalVersionByNameAndVersion gets a version by name and version number
func GetOrInsertVersion ¶
func GetOrInsertVersion(ctx context.Context, pv *PackageVersion) (*PackageVersion, error)
GetOrInsertVersion inserts a version. If the same version exist already ErrDuplicatePackageVersion is returned
func GetVersionByID ¶
func GetVersionByID(ctx context.Context, versionID int64) (*PackageVersion, error)
GetVersionByID gets a version by id
func GetVersionByNameAndVersion ¶
func GetVersionByNameAndVersion(ctx context.Context, ownerID int64, packageType Type, name, version string) (*PackageVersion, error)
GetVersionByNameAndVersion gets a version by name and version number
func GetVersionsByPackageName ¶
func GetVersionsByPackageName(ctx context.Context, ownerID int64, packageType Type, name string) ([]*PackageVersion, error)
GetVersionsByPackageName gets all versions of a specific package
func GetVersionsByPackageType ¶
func GetVersionsByPackageType(ctx context.Context, ownerID int64, packageType Type) ([]*PackageVersion, error)
GetVersionsByPackageType gets all versions of a specific type
func SearchLatestVersions ¶
func SearchLatestVersions(ctx context.Context, opts *PackageSearchOptions) ([]*PackageVersion, int64, error)
SearchLatestVersions gets the latest version of every package matching the search options
func SearchVersions ¶
func SearchVersions(ctx context.Context, opts *PackageSearchOptions) ([]*PackageVersion, int64, error)
SearchVersions gets all versions of packages matching the search options
type PropertyType ¶
type PropertyType int64
const ( // PropertyTypeVersion means the reference is a package version PropertyTypeVersion PropertyType = iota // 0 // PropertyTypeFile means the reference is a package file PropertyTypeFile // 1 // PropertyTypePackage means the reference is a package PropertyTypePackage // 2 )
type SearchValue ¶
SearchValue describes a value to search If ExactMatch is true, the field must match the value otherwise a LIKE search is performed.
type Type ¶
type Type string
Type of a package
const ( TypeAlpine Type = "alpine" TypeCargo Type = "cargo" TypeChef Type = "chef" TypeComposer Type = "composer" TypeConan Type = "conan" TypeConda Type = "conda" TypeContainer Type = "container" TypeCran Type = "cran" TypeDebian Type = "debian" TypeGeneric Type = "generic" TypeGo Type = "go" TypeHelm Type = "helm" TypeMaven Type = "maven" TypeNpm Type = "npm" TypeNuGet Type = "nuget" TypePub Type = "pub" TypePyPI Type = "pypi" TypeRpm Type = "rpm" TypeRubyGems Type = "rubygems" TypeSwift Type = "swift" TypeVagrant Type = "vagrant" )
List of supported packages
type VersionSort ¶
type VersionSort = string
const ( SortNameAsc VersionSort = "name_asc" SortNameDesc VersionSort = "name_desc" SortVersionAsc VersionSort = "version_asc" SortVersionDesc VersionSort = "version_desc" SortCreatedAsc VersionSort = "created_asc" SortCreatedDesc VersionSort = "created_desc" )