Documentation
¶
Index ¶
- Variables
- func AddFileToExistingPackage(ctx context.Context, pvi *PackageInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageFile, error)
- func AddFileToPackageVersionInternal(ctx context.Context, pv *packages_model.PackageVersion, ...) (*packages_model.PackageFile, error)
- func CheckCountQuotaExceeded(ctx context.Context, doer, owner *user_model.User) error
- func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, ...) error
- func CreateAuthorizationToken(u *user_model.User, packageScope auth_model.AccessTokenScope) (string, error)
- func CreatePackageAndAddFile(ctx context.Context, pvci *PackageCreationInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageVersion, *packages_model.PackageFile, error)
- func CreatePackageOrAddFileToExisting(ctx context.Context, pvci *PackageCreationInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageVersion, *packages_model.PackageFile, error)
- func DeletePackageFile(ctx context.Context, pf *packages_model.PackageFile) error
- func DeletePackageVersionAndReferences(ctx context.Context, pv *packages_model.PackageVersion) error
- func GetOrCreateInternalPackageVersion(ctx context.Context, ownerID int64, packageType packages_model.Type, ...) (*packages_model.PackageVersion, error)
- func LinkToRepository(ctx context.Context, pkg *packages_model.Package, repo *repo_model.Repository, ...) error
- func NewPackageBlob(hsr packages_module.HashedSizeReader) *packages_model.PackageBlob
- func OpenBlobForDownload(ctx context.Context, pf *packages_model.PackageFile, ...) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
- func OpenBlobStream(pb *packages_model.PackageBlob) (io.ReadSeekCloser, error)
- func OpenFileForDownload(ctx context.Context, pf *packages_model.PackageFile, method string) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
- func OpenFileForDownloadByPackageNameAndVersion(ctx context.Context, pvi *PackageInfo, pfi *PackageFileInfo, method string) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
- func OpenFileForDownloadByPackageVersion(ctx context.Context, pv *packages_model.PackageVersion, pfi *PackageFileInfo, ...) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
- func RemoveAllPackages(ctx context.Context, userID int64) (int, error)
- func RemovePackageFileAndVersionIfUnreferenced(ctx context.Context, doer *user_model.User, pf *packages_model.PackageFile) error
- func RemovePackageVersion(ctx context.Context, doer *user_model.User, pv *packages_model.PackageVersion) error
- func RemovePackageVersionByNameAndVersion(ctx context.Context, doer *user_model.User, pvi *PackageInfo) error
- func UnlinkFromRepository(ctx context.Context, pkg *packages_model.Package, doer *user_model.User) error
- type PackageCreationInfo
- type PackageFileCreationInfo
- type PackageFileInfo
- type PackageInfo
- type PackageMeta
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddFileToExistingPackage ¶
func AddFileToExistingPackage(ctx context.Context, pvi *PackageInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageFile, error)
AddFileToExistingPackage adds a file to an existing package. If the package does not exist, ErrPackageNotExist is returned
func AddFileToPackageVersionInternal ¶ added in v1.20.0
func AddFileToPackageVersionInternal(ctx context.Context, pv *packages_model.PackageVersion, pfci *PackageFileCreationInfo) (*packages_model.PackageFile, error)
AddFileToPackageVersionInternal adds a file to the package This method skips quota checks and should only be used for system-managed packages.
func CheckCountQuotaExceeded ¶ added in v1.19.0
func CheckCountQuotaExceeded(ctx context.Context, doer, owner *user_model.User) error
CheckCountQuotaExceeded checks if the owner has more than the allowed packages The check is skipped if the doer is an admin.
func CheckSizeQuotaExceeded ¶ added in v1.19.0
func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, packageType packages_model.Type, uploadSize int64) error
CheckSizeQuotaExceeded checks if the upload size is bigger than the allowed size The check is skipped if the doer is an admin.
func CreateAuthorizationToken ¶
func CreateAuthorizationToken(u *user_model.User, packageScope auth_model.AccessTokenScope) (string, error)
func CreatePackageAndAddFile ¶
func CreatePackageAndAddFile(ctx context.Context, pvci *PackageCreationInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageVersion, *packages_model.PackageFile, error)
CreatePackageAndAddFile creates a package with a file. If the same package exists already, ErrDuplicatePackageVersion is returned
func CreatePackageOrAddFileToExisting ¶
func CreatePackageOrAddFileToExisting(ctx context.Context, pvci *PackageCreationInfo, pfci *PackageFileCreationInfo) (*packages_model.PackageVersion, *packages_model.PackageFile, error)
CreatePackageOrAddFileToExisting creates a package with a file or adds the file if the package exists already
func DeletePackageFile ¶
func DeletePackageFile(ctx context.Context, pf *packages_model.PackageFile) error
DeletePackageFile deletes the package file and its properties
func DeletePackageVersionAndReferences ¶
func DeletePackageVersionAndReferences(ctx context.Context, pv *packages_model.PackageVersion) error
DeletePackageVersionAndReferences deletes the package version and its properties and files
func GetOrCreateInternalPackageVersion ¶ added in v1.20.0
func GetOrCreateInternalPackageVersion(ctx context.Context, ownerID int64, packageType packages_model.Type, name, version string) (*packages_model.PackageVersion, error)
GetOrCreateInternalPackageVersion gets or creates an internal package Some package types need such internal packages for housekeeping.
func LinkToRepository ¶ added in v1.24.0
func LinkToRepository(ctx context.Context, pkg *packages_model.Package, repo *repo_model.Repository, doer *user_model.User) error
func NewPackageBlob ¶
func NewPackageBlob(hsr packages_module.HashedSizeReader) *packages_model.PackageBlob
NewPackageBlob creates a package blob instance
func OpenBlobForDownload ¶
func OpenBlobForDownload(ctx context.Context, pf *packages_model.PackageFile, pb *packages_model.PackageBlob, method string, serveDirectReqParams url.Values) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
OpenBlobForDownload returns the content of the specific package blob and increases the download counter. If the storage supports direct serving and it's enabled, only the direct serving url is returned.
func OpenBlobStream ¶
func OpenBlobStream(pb *packages_model.PackageBlob) (io.ReadSeekCloser, error)
func OpenFileForDownload ¶
func OpenFileForDownload(ctx context.Context, pf *packages_model.PackageFile, method string) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
OpenFileForDownload returns the content of the specific package file and increases the download counter.
func OpenFileForDownloadByPackageNameAndVersion ¶
func OpenFileForDownloadByPackageNameAndVersion(ctx context.Context, pvi *PackageInfo, pfi *PackageFileInfo, method string) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
OpenFileForDownloadByPackageNameAndVersion returns the content of the specific package file and increases the download counter.
func OpenFileForDownloadByPackageVersion ¶
func OpenFileForDownloadByPackageVersion(ctx context.Context, pv *packages_model.PackageVersion, pfi *PackageFileInfo, method string) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error)
OpenFileForDownloadByPackageVersion returns the content of the specific package file and increases the download counter.
func RemoveAllPackages ¶ added in v1.17.4
RemoveAllPackages for User
func RemovePackageFileAndVersionIfUnreferenced ¶ added in v1.20.0
func RemovePackageFileAndVersionIfUnreferenced(ctx context.Context, doer *user_model.User, pf *packages_model.PackageFile) error
RemovePackageFileAndVersionIfUnreferenced deletes the package file and the version if there are no referenced files afterwards
func RemovePackageVersion ¶
func RemovePackageVersion(ctx context.Context, doer *user_model.User, pv *packages_model.PackageVersion) error
RemovePackageVersion deletes the package version and all associated files
func RemovePackageVersionByNameAndVersion ¶
func RemovePackageVersionByNameAndVersion(ctx context.Context, doer *user_model.User, pvi *PackageInfo) error
RemovePackageVersionByNameAndVersion deletes a package version and all associated files
func UnlinkFromRepository ¶ added in v1.24.0
func UnlinkFromRepository(ctx context.Context, pkg *packages_model.Package, doer *user_model.User) error
Types ¶
type PackageCreationInfo ¶
type PackageCreationInfo struct { PackageInfo SemverCompatible bool Creator *user_model.User Metadata any PackageProperties map[string]string VersionProperties map[string]string }
PackageCreationInfo describes a package to create
type PackageFileCreationInfo ¶
type PackageFileCreationInfo struct { PackageFileInfo Creator *user_model.User Data packages_module.HashedSizeReader IsLead bool Properties map[string]string OverwriteExisting bool }
PackageFileCreationInfo describes a package file to create
type PackageFileInfo ¶
PackageFileInfo describes a package file
type PackageInfo ¶
type PackageInfo struct { Owner *user_model.User PackageType packages_model.Type Name string Version string }
PackageInfo describes a package
type PackageMeta ¶ added in v1.22.2
type PackageMeta struct { UserID int64 Scope auth_model.AccessTokenScope }
func ParseAuthorizationRequest ¶ added in v1.22.2
func ParseAuthorizationRequest(req *http.Request) (*PackageMeta, error)
func ParseAuthorizationToken ¶
func ParseAuthorizationToken(tokenStr string) (*PackageMeta, error)