database

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package database provides a base mock for the Database interface. Embed BaseMockDB in test mocks and override only the methods you need.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSBOMReportNotFound    = errors.New("SBOM report not found")
	ErrLicensePolicyNotFound = errors.New("license policy not found")
	// ErrCreateComponentDeprecated is returned by CreateComponent, which was
	// split into CreateDebPackage and CreateRpmPackage.
	ErrCreateComponentDeprecated = errors.New("CreateComponent is deprecated: use CreateDebPackage or CreateRpmPackage, passing distribution_id and component_id for DEB")
)
View Source
var (
	// ErrVulnScanNotFound is returned when a vuln scan result does not exist in the repository.
	ErrVulnScanNotFound = errors.New("vuln scan result not found")

	// ErrBundleNotDraft is returned when a bundle mutation requires the draft state.
	ErrBundleNotDraft = errors.New("release bundle is not in draft state")

	// ErrBundleNotFound is returned when a release bundle does not exist.
	ErrBundleNotFound = errors.New("release bundle not found")
)
View Source
var ErrChecksumDrift = errors.New("checksum drift")
View Source
var ErrDuplicate = errors.New("artifact already exists")

ErrDuplicate is returned by Create*Package when an insert hits the unique constraint (ON CONFLICT), so callers can distinguish an idempotent duplicate upload (map to HTTP 409) from a real failure. This closes the check-then-insert TOCTOU: concurrent identical uploads race the existence check, but exactly one INSERT wins and the losers observe ErrDuplicate.

View Source
var ErrInvalidAuditLimit = errors.New("audit page limit must be positive")

ErrInvalidAuditLimit is returned by ListAuditLogs for a page size below 1.

View Source
var ErrInvalidConnOption = errors.New("invalid database option key")

ErrInvalidConnOption is returned when a database option key is not a valid PostgreSQL runtime parameter name.

View Source
var ErrLicenseScanNotFound = errors.New("license scan result not found")

ErrLicenseScanNotFound is returned when a license scan result does not exist in the repository.

View Source
var ErrMockNotImplemented = errors.New("BaseMockDB method not implemented")

ErrMockNotImplemented is returned by BaseMockDB methods a test has not overridden.

Functions

func IsForeignKeyViolation added in v0.2.0

func IsForeignKeyViolation(err error) bool

IsForeignKeyViolation reports whether err is a PostgreSQL foreign_key_violation or restrict_violation: a referenced row cannot be removed or a referencing row points nowhere.

func IsUniqueViolation added in v0.2.0

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a PostgreSQL unique_violation.

func UniqueViolationConstraint added in v0.2.0

func UniqueViolationConstraint(err error) string

UniqueViolationConstraint returns the violated constraint/index name when err is a unique_violation, and "" otherwise.

Types

type BaseMockDB

type BaseMockDB struct{}

BaseMockDB provides stub implementations of every Database method.

func (*BaseMockDB) AddBundleItem

func (m *BaseMockDB) AddBundleItem(ctx context.Context, item *models.ReleaseBundleItem) error

func (*BaseMockDB) AddBundleItems added in v0.2.0

func (m *BaseMockDB) AddBundleItems(ctx context.Context, bundleID string, items []*models.ReleaseBundleItem) error

func (*BaseMockDB) AddGroupMember

func (m *BaseMockDB) AddGroupMember(ctx context.Context, groupRepoID, memberRepoID string, priority int) error

func (*BaseMockDB) AddOrgMember

func (m *BaseMockDB) AddOrgMember(ctx context.Context, orgID, userID, role string) error

func (*BaseMockDB) AddUserToGroup

func (m *BaseMockDB) AddUserToGroup(ctx context.Context, userID, groupID string) error

func (*BaseMockDB) ArtifactExists

func (m *BaseMockDB) ArtifactExists(ctx context.Context, sha256 string, repositoryID string) (bool, error)

func (*BaseMockDB) ArtifactExistsBySHA256

func (m *BaseMockDB) ArtifactExistsBySHA256(ctx context.Context, sha256 string) (string, bool, error)

func (*BaseMockDB) BeginTx

func (m *BaseMockDB) BeginTx(ctx context.Context) (Transaction, error)

func (*BaseMockDB) BlobReferenceCount

func (m *BaseMockDB) BlobReferenceCount(ctx context.Context, sha256 string) (int, error)

func (*BaseMockDB) ClaimPendingWebhookDeliveries added in v0.2.0

func (m *BaseMockDB) ClaimPendingWebhookDeliveries(ctx context.Context, limit int, lease time.Duration) ([]*models.WebhookDelivery, error)

func (*BaseMockDB) Close

func (m *BaseMockDB) Close() error

func (*BaseMockDB) ConsumeSAMLAssertion added in v0.2.0

func (m *BaseMockDB) ConsumeSAMLAssertion(ctx context.Context, providerSlug, assertionID string, expiresAt time.Time) (bool, error)

func (*BaseMockDB) CountBlobsOnStorageBackend added in v0.2.0

func (m *BaseMockDB) CountBlobsOnStorageBackend(ctx context.Context, backendID string) (int64, error)

func (*BaseMockDB) CountRepositories

func (m *BaseMockDB) CountRepositories(ctx context.Context, formatFilter string) (int, error)

func (*BaseMockDB) CountUsers

func (m *BaseMockDB) CountUsers(ctx context.Context) (int, error)

func (*BaseMockDB) CreateBackupJob

func (m *BaseMockDB) CreateBackupJob(ctx context.Context, job *models.BackupJob) error

func (*BaseMockDB) CreateBootstrapAdmin added in v0.2.0

func (m *BaseMockDB) CreateBootstrapAdmin(ctx context.Context, username, passwordHash string) (bool, error)

func (*BaseMockDB) CreateBundlePromotion

func (m *BaseMockDB) CreateBundlePromotion(ctx context.Context, p *models.BundlePromotion) error

func (*BaseMockDB) CreateCargoCrate

func (m *BaseMockDB) CreateCargoCrate(ctx context.Context, crate *models.CargoCrate) error

func (*BaseMockDB) CreateCleanupPolicy

func (m *BaseMockDB) CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error

func (*BaseMockDB) CreateComponent

func (m *BaseMockDB) CreateComponent(ctx context.Context, component *models.Component) error

func (*BaseMockDB) CreateConanPackage

func (m *BaseMockDB) CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error

func (*BaseMockDB) CreateCondaPackage

func (m *BaseMockDB) CreateCondaPackage(ctx context.Context, pkg *models.CondaPackage) error

func (*BaseMockDB) CreateDebPackage

func (m *BaseMockDB) CreateDebPackage(ctx context.Context, pkg *models.Component, distID, compID string) error

func (*BaseMockDB) CreateDebianArchitecture

func (m *BaseMockDB) CreateDebianArchitecture(ctx context.Context, arch *models.DebianArchitecture) error

func (*BaseMockDB) CreateDebianComponent

func (m *BaseMockDB) CreateDebianComponent(ctx context.Context, comp *models.DebianComponent) error

func (*BaseMockDB) CreateDebianDistribution

func (m *BaseMockDB) CreateDebianDistribution(ctx context.Context, dist *models.DebianDistribution) error

func (*BaseMockDB) CreateDockerBlob

func (m *BaseMockDB) CreateDockerBlob(ctx context.Context, blob *models.DockerBlob) error

func (*BaseMockDB) CreateDockerManifest

func (m *BaseMockDB) CreateDockerManifest(ctx context.Context, mf *models.DockerManifest) error

func (*BaseMockDB) CreateDockerUpload

func (m *BaseMockDB) CreateDockerUpload(ctx context.Context, upload *models.DockerUpload) error

func (*BaseMockDB) CreateGoModule

func (m *BaseMockDB) CreateGoModule(ctx context.Context, mod *models.GoModule) error

func (*BaseMockDB) CreateGroup

func (m *BaseMockDB) CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)

func (*BaseMockDB) CreateHelmChart

func (m *BaseMockDB) CreateHelmChart(ctx context.Context, chart *models.HelmChart) error

func (*BaseMockDB) CreateIvyArtifact

func (m *BaseMockDB) CreateIvyArtifact(ctx context.Context, artifact *models.IvyArtifact) error

func (*BaseMockDB) CreateLicensePolicy

func (m *BaseMockDB) CreateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error

func (*BaseMockDB) CreateLicenseScanResult

func (m *BaseMockDB) CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error

func (*BaseMockDB) CreateMavenArtifact

func (m *BaseMockDB) CreateMavenArtifact(ctx context.Context, a *models.MavenArtifact) error

func (*BaseMockDB) CreateNPMPackage

func (m *BaseMockDB) CreateNPMPackage(ctx context.Context, p *models.NPMPackage) (*models.NPMPackage, error)

func (*BaseMockDB) CreateNPMVersion

func (m *BaseMockDB) CreateNPMVersion(ctx context.Context, v *models.NPMVersion) (*models.NPMVersion, error)

func (*BaseMockDB) CreateNuGetPackage

func (m *BaseMockDB) CreateNuGetPackage(ctx context.Context, pkg *models.NuGetPackage) error

func (*BaseMockDB) CreateOrganization

func (m *BaseMockDB) CreateOrganization(ctx context.Context, org *models.Organization) error

func (*BaseMockDB) CreatePackageDelta

func (m *BaseMockDB) CreatePackageDelta(ctx context.Context, delta *models.PackageDelta) error

func (*BaseMockDB) CreatePermissionAssignment

func (m *BaseMockDB) CreatePermissionAssignment(ctx context.Context, assignment *models.PermissionAssignment) error

func (*BaseMockDB) CreatePermissionTarget

func (m *BaseMockDB) CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)

func (*BaseMockDB) CreatePromotionPipeline

func (m *BaseMockDB) CreatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error

func (*BaseMockDB) CreatePyPIPackage

func (m *BaseMockDB) CreatePyPIPackage(ctx context.Context, pkg *models.PyPIPackage) error

func (*BaseMockDB) CreateRPMRepo

func (m *BaseMockDB) CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error

func (*BaseMockDB) CreateReleaseBundle

func (m *BaseMockDB) CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error

func (*BaseMockDB) CreateRepository

func (m *BaseMockDB) CreateRepository(ctx context.Context, repo *models.Repository) error

func (*BaseMockDB) CreateRepositoryWithMembers added in v0.2.0

func (m *BaseMockDB) CreateRepositoryWithMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error

func (*BaseMockDB) CreateRpmPackage

func (m *BaseMockDB) CreateRpmPackage(ctx context.Context, pkg *models.Component) error

func (*BaseMockDB) CreateRubyGem

func (m *BaseMockDB) CreateRubyGem(ctx context.Context, gem *models.RubyGem) error

func (*BaseMockDB) CreateSBOMReport

func (m *BaseMockDB) CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error

func (*BaseMockDB) CreateSBTArtifact

func (m *BaseMockDB) CreateSBTArtifact(ctx context.Context, artifact *models.SBTArtifact) error

func (*BaseMockDB) CreateSSOProvider

func (m *BaseMockDB) CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error

func (*BaseMockDB) CreateSecretScanResult

func (m *BaseMockDB) CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error

func (*BaseMockDB) CreateSession

func (m *BaseMockDB) CreateSession(ctx context.Context, session *models.Session) (*models.Session, error)

func (*BaseMockDB) CreateStorageBackend

func (m *BaseMockDB) CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error

func (*BaseMockDB) CreateToken

func (m *BaseMockDB) CreateToken(ctx context.Context, token *models.Token) (*models.Token, error)

func (*BaseMockDB) CreateUser

func (m *BaseMockDB) CreateUser(ctx context.Context, user *models.User) (*models.User, error)

func (*BaseMockDB) CreateVulnScanResult

func (m *BaseMockDB) CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error

func (*BaseMockDB) CreateWebhook

func (m *BaseMockDB) CreateWebhook(ctx context.Context, wh *models.Webhook) error

func (*BaseMockDB) CreateWebhookDelivery

func (m *BaseMockDB) CreateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error

func (*BaseMockDB) DecrementStorageUsage

func (m *BaseMockDB) DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error

func (*BaseMockDB) DeleteAIAnalysis

func (m *BaseMockDB) DeleteAIAnalysis(ctx context.Context, repoID, artifactID string) error

func (*BaseMockDB) DeleteArtifactProperty

func (m *BaseMockDB) DeleteArtifactProperty(ctx context.Context, repoID, artifactID, key string) error

func (*BaseMockDB) DeleteCargoCrate

func (m *BaseMockDB) DeleteCargoCrate(ctx context.Context, id string) error

func (*BaseMockDB) DeleteCleanupPolicy

func (m *BaseMockDB) DeleteCleanupPolicy(ctx context.Context, id string) error

func (*BaseMockDB) DeleteComponent

func (m *BaseMockDB) DeleteComponent(ctx context.Context, componentID string) error

func (*BaseMockDB) DeleteConanPackage

func (m *BaseMockDB) DeleteConanPackage(ctx context.Context, id string) error

func (*BaseMockDB) DeleteCondaPackage

func (m *BaseMockDB) DeleteCondaPackage(ctx context.Context, id string) error

func (*BaseMockDB) DeleteDockerBlob

func (m *BaseMockDB) DeleteDockerBlob(ctx context.Context, repoID, digest string) error

func (*BaseMockDB) DeleteDockerManifest

func (m *BaseMockDB) DeleteDockerManifest(ctx context.Context, repoID, image, digest string) error

func (*BaseMockDB) DeleteDockerTag

func (m *BaseMockDB) DeleteDockerTag(ctx context.Context, repoID, image, name string) error

func (*BaseMockDB) DeleteDockerTagsByDigest added in v0.4.0

func (m *BaseMockDB) DeleteDockerTagsByDigest(ctx context.Context, repoID, image, digest string) error

func (*BaseMockDB) DeleteDockerUpload

func (m *BaseMockDB) DeleteDockerUpload(ctx context.Context, repositoryID, uploadUUID string) error

func (*BaseMockDB) DeleteExpiredProxyCacheEntries

func (m *BaseMockDB) DeleteExpiredProxyCacheEntries(ctx context.Context) (int64, error)

func (*BaseMockDB) DeleteGoModule

func (m *BaseMockDB) DeleteGoModule(ctx context.Context, repoID, modulePath, version string) error

func (*BaseMockDB) DeleteGroup

func (m *BaseMockDB) DeleteGroup(ctx context.Context, id string) error

func (*BaseMockDB) DeleteHelmChart

func (m *BaseMockDB) DeleteHelmChart(ctx context.Context, repoID, name, version string) error

func (*BaseMockDB) DeleteIvyArtifact

func (m *BaseMockDB) DeleteIvyArtifact(ctx context.Context, id string) error

func (*BaseMockDB) DeleteLicensePolicy

func (m *BaseMockDB) DeleteLicensePolicy(ctx context.Context, id string) error

func (*BaseMockDB) DeleteMavenArtifact

func (m *BaseMockDB) DeleteMavenArtifact(ctx context.Context, id string) error

func (*BaseMockDB) DeleteNPMDistTag

func (m *BaseMockDB) DeleteNPMDistTag(ctx context.Context, packageID, tag string) error

func (*BaseMockDB) DeleteNPMPackage

func (m *BaseMockDB) DeleteNPMPackage(ctx context.Context, packageID string) error

func (*BaseMockDB) DeleteNPMVersion

func (m *BaseMockDB) DeleteNPMVersion(ctx context.Context, packageID, version string) error

func (*BaseMockDB) DeleteNuGetPackage

func (m *BaseMockDB) DeleteNuGetPackage(ctx context.Context, repoID, packageID, version string) error

func (*BaseMockDB) DeleteOrganization

func (m *BaseMockDB) DeleteOrganization(ctx context.Context, id string) error

func (*BaseMockDB) DeleteOtherSessionsByUser added in v0.2.0

func (m *BaseMockDB) DeleteOtherSessionsByUser(ctx context.Context, userID, keepTokenHash string) error

func (*BaseMockDB) DeletePackageDelta

func (m *BaseMockDB) DeletePackageDelta(ctx context.Context, id string) error

func (*BaseMockDB) DeletePermissionAssignment

func (m *BaseMockDB) DeletePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error

func (*BaseMockDB) DeletePermissionTarget

func (m *BaseMockDB) DeletePermissionTarget(ctx context.Context, id string) error

func (*BaseMockDB) DeletePromotionPipeline

func (m *BaseMockDB) DeletePromotionPipeline(ctx context.Context, id string) error

func (*BaseMockDB) DeleteProxyCacheEntry

func (m *BaseMockDB) DeleteProxyCacheEntry(ctx context.Context, repoID, cacheKey string) error

func (*BaseMockDB) DeletePyPIPackage

func (m *BaseMockDB) DeletePyPIPackage(ctx context.Context, repoID, name, version, filename string) error

func (*BaseMockDB) DeleteRawArtifact

func (m *BaseMockDB) DeleteRawArtifact(ctx context.Context, repoID, path string) error

func (*BaseMockDB) DeleteReleaseBundle

func (m *BaseMockDB) DeleteReleaseBundle(ctx context.Context, id string) error

func (*BaseMockDB) DeleteRepository

func (m *BaseMockDB) DeleteRepository(ctx context.Context, id string) error

func (*BaseMockDB) DeleteRubyGem

func (m *BaseMockDB) DeleteRubyGem(ctx context.Context, id string) error

func (*BaseMockDB) DeleteSBOMReport

func (m *BaseMockDB) DeleteSBOMReport(ctx context.Context, id string) error

func (*BaseMockDB) DeleteSBOMReportInRepo added in v0.2.0

func (m *BaseMockDB) DeleteSBOMReportInRepo(ctx context.Context, repoID, id string) (string, error)

func (*BaseMockDB) DeleteSBTArtifact

func (m *BaseMockDB) DeleteSBTArtifact(ctx context.Context, id string) error

func (*BaseMockDB) DeleteSSOProvider

func (m *BaseMockDB) DeleteSSOProvider(ctx context.Context, id string) error

func (*BaseMockDB) DeleteSession

func (m *BaseMockDB) DeleteSession(ctx context.Context, tokenHash string) error

func (*BaseMockDB) DeleteSessionsByUser added in v0.2.0

func (m *BaseMockDB) DeleteSessionsByUser(ctx context.Context, userID string) error

func (*BaseMockDB) DeleteStorageBackend

func (m *BaseMockDB) DeleteStorageBackend(ctx context.Context, id string) error

func (*BaseMockDB) DeleteVulnScanResult added in v0.2.0

func (m *BaseMockDB) DeleteVulnScanResult(ctx context.Context, repoID, id string) error

func (*BaseMockDB) DeleteWebhook

func (m *BaseMockDB) DeleteWebhook(ctx context.Context, id string) error

func (*BaseMockDB) EnsureBlob

func (m *BaseMockDB) EnsureBlob(ctx context.Context, sha256, mediaType string, size int64) (string, error)

func (*BaseMockDB) GetAIAnalysis

func (m *BaseMockDB) GetAIAnalysis(ctx context.Context, repoID, artifactID string) (*models.AIAnalysis, error)

func (*BaseMockDB) GetArtifactProperty

func (m *BaseMockDB) GetArtifactProperty(ctx context.Context, repoID, artifactID, key string) (string, error)

func (*BaseMockDB) GetBackupJob

func (m *BaseMockDB) GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)

func (*BaseMockDB) GetBundleItem

func (m *BaseMockDB) GetBundleItem(ctx context.Context, bundleID, sha256 string) (*models.ReleaseBundleItem, error)

func (*BaseMockDB) GetCargoCrate

func (m *BaseMockDB) GetCargoCrate(ctx context.Context, repoID, name, version string) (*models.CargoCrate, error)

func (*BaseMockDB) GetCleanupPolicy

func (m *BaseMockDB) GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)

func (*BaseMockDB) GetComponentByFilename

func (m *BaseMockDB) GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)

func (*BaseMockDB) GetComponentByID

func (m *BaseMockDB) GetComponentByID(ctx context.Context, id string) (*models.Component, error)

func (*BaseMockDB) GetComponentsByRepo

func (m *BaseMockDB) GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)

func (*BaseMockDB) GetConanPackage

func (m *BaseMockDB) GetConanPackage(ctx context.Context, repoID, name, version, userChannel, recipeRevision string) (*models.ConanPackage, error)

func (*BaseMockDB) GetCondaPackage

func (m *BaseMockDB) GetCondaPackage(ctx context.Context, repoID, name, version, buildString, platform string) (*models.CondaPackage, error)

func (*BaseMockDB) GetDB

func (m *BaseMockDB) GetDB() *sql.DB

func (*BaseMockDB) GetDebBlobInfo added in v0.2.0

func (m *BaseMockDB) GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)

func (*BaseMockDB) GetDebPackageByID

func (m *BaseMockDB) GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)

func (*BaseMockDB) GetDebianArchitecturesByDist

func (m *BaseMockDB) GetDebianArchitecturesByDist(ctx context.Context, distID string) ([]models.DebianArchitecture, error)

func (*BaseMockDB) GetDebianComponentsByDist

func (m *BaseMockDB) GetDebianComponentsByDist(ctx context.Context, distID string) ([]models.DebianComponent, error)

func (*BaseMockDB) GetDebianDistribution

func (m *BaseMockDB) GetDebianDistribution(ctx context.Context, repoID string, name string) (*models.DebianDistribution, error)

func (*BaseMockDB) GetDebianDistributionsByRepo

func (m *BaseMockDB) GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)

func (*BaseMockDB) GetDebianPackageByFilename

func (m *BaseMockDB) GetDebianPackageByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)

func (*BaseMockDB) GetDebianPackagesByDistComp

func (m *BaseMockDB) GetDebianPackagesByDistComp(ctx context.Context, repoID string, dist string, comp string, arch string) ([]models.Component, error)

func (*BaseMockDB) GetDockerBlob

func (m *BaseMockDB) GetDockerBlob(ctx context.Context, repoID, digest string) (*models.DockerBlob, error)

func (*BaseMockDB) GetDockerManifest

func (m *BaseMockDB) GetDockerManifest(ctx context.Context, repoID, image, digest string) (*models.DockerManifest, error)

func (*BaseMockDB) GetDockerTag

func (m *BaseMockDB) GetDockerTag(ctx context.Context, repoID, image, name string) (*models.DockerTag, error)

func (*BaseMockDB) GetDockerUpload

func (m *BaseMockDB) GetDockerUpload(ctx context.Context, repositoryID, uploadUUID string) (*models.DockerUpload, error)

func (*BaseMockDB) GetGoModule

func (m *BaseMockDB) GetGoModule(ctx context.Context, repoID, modulePath, version string) (*models.GoModule, error)

func (*BaseMockDB) GetGroupByID

func (m *BaseMockDB) GetGroupByID(ctx context.Context, id string) (*models.Group, error)

func (*BaseMockDB) GetGroupByName

func (m *BaseMockDB) GetGroupByName(ctx context.Context, name string) (*models.Group, error)

func (*BaseMockDB) GetHelmChart

func (m *BaseMockDB) GetHelmChart(ctx context.Context, repoID, name, version string) (*models.HelmChart, error)

func (*BaseMockDB) GetIvyArtifact

func (m *BaseMockDB) GetIvyArtifact(ctx context.Context, repoID, organisation, module, revision, artifactName, artifactExt string) (*models.IvyArtifact, error)

func (*BaseMockDB) GetLatestGoModule

func (m *BaseMockDB) GetLatestGoModule(ctx context.Context, repoID, modulePath string) (*models.GoModule, error)

func (*BaseMockDB) GetLatestSnapshot

func (m *BaseMockDB) GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)

func (*BaseMockDB) GetLicensePolicy

func (m *BaseMockDB) GetLicensePolicy(ctx context.Context, id string) (*models.LicensePolicy, error)

func (*BaseMockDB) GetLicenseScanResult

func (m *BaseMockDB) GetLicenseScanResult(ctx context.Context, repoID, artifactID string) (*models.LicenseScanResult, error)

func (*BaseMockDB) GetLicenseScanResultByID added in v0.2.0

func (m *BaseMockDB) GetLicenseScanResultByID(ctx context.Context, repoID, id string) (*models.LicenseScanResult, error)

func (*BaseMockDB) GetMavenArtifactByPath

func (m *BaseMockDB) GetMavenArtifactByPath(ctx context.Context, repoID, path string) (*models.MavenArtifact, error)

func (*BaseMockDB) GetMavenArtifactsByGA

func (m *BaseMockDB) GetMavenArtifactsByGA(ctx context.Context, repoID, groupID, artifactID string) ([]*models.MavenArtifact, error)

func (*BaseMockDB) GetMavenArtifactsByGAV

func (m *BaseMockDB) GetMavenArtifactsByGAV(ctx context.Context, repoID, groupID, artifactID, version string) ([]*models.MavenArtifact, error)

func (*BaseMockDB) GetNPMDistTags

func (m *BaseMockDB) GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)

func (*BaseMockDB) GetNPMPackageByName

func (m *BaseMockDB) GetNPMPackageByName(ctx context.Context, repoID, fullName string) (*models.NPMPackage, error)

func (*BaseMockDB) GetNPMVersion

func (m *BaseMockDB) GetNPMVersion(ctx context.Context, packageID, version string) (*models.NPMVersion, error)

func (*BaseMockDB) GetNPMVersionsByPackage

func (m *BaseMockDB) GetNPMVersionsByPackage(ctx context.Context, packageID string) ([]*models.NPMVersion, error)

func (*BaseMockDB) GetNuGetPackage

func (m *BaseMockDB) GetNuGetPackage(ctx context.Context, repoID, packageID, version string) (*models.NuGetPackage, error)

func (*BaseMockDB) GetOrCreateDebianArchitecture added in v0.2.0

func (m *BaseMockDB) GetOrCreateDebianArchitecture(ctx context.Context, distID, name string) (*models.DebianArchitecture, error)

func (*BaseMockDB) GetOrCreateDebianComponent added in v0.2.0

func (m *BaseMockDB) GetOrCreateDebianComponent(ctx context.Context, distID, name string) (*models.DebianComponent, error)

func (*BaseMockDB) GetOrCreateDebianDistribution added in v0.2.0

func (m *BaseMockDB) GetOrCreateDebianDistribution(ctx context.Context, repoID, name string) (*models.DebianDistribution, error)

func (*BaseMockDB) GetOrCreateGroup

func (m *BaseMockDB) GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)

func (*BaseMockDB) GetOrCreatePermissionAssignment

func (m *BaseMockDB) GetOrCreatePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error

func (*BaseMockDB) GetOrCreateStorageQuota

func (m *BaseMockDB) GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)

func (*BaseMockDB) GetOrgMember

func (m *BaseMockDB) GetOrgMember(ctx context.Context, orgID, userID string) (*models.OrgMember, error)

func (*BaseMockDB) GetOrganization

func (m *BaseMockDB) GetOrganization(ctx context.Context, id string) (*models.Organization, error)

func (*BaseMockDB) GetOrganizationByName

func (m *BaseMockDB) GetOrganizationByName(ctx context.Context, name string) (*models.Organization, error)

func (*BaseMockDB) GetPackageDelta

func (m *BaseMockDB) GetPackageDelta(ctx context.Context, repoID, fromSHA256, toSHA256 string) (*models.PackageDelta, error)

func (*BaseMockDB) GetPermissionTargetByID

func (m *BaseMockDB) GetPermissionTargetByID(ctx context.Context, id string) (*models.PermissionTarget, error)

func (*BaseMockDB) GetPermissionTargetByName

func (m *BaseMockDB) GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)

func (*BaseMockDB) GetPermissionTargetsForPrincipal

func (m *BaseMockDB) GetPermissionTargetsForPrincipal(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)

func (*BaseMockDB) GetPromotionPipelineByID

func (m *BaseMockDB) GetPromotionPipelineByID(ctx context.Context, id string) (*models.PromotionPipeline, error)

func (*BaseMockDB) GetPromotionPipelineByName

func (m *BaseMockDB) GetPromotionPipelineByName(ctx context.Context, name string) (*models.PromotionPipeline, error)

func (*BaseMockDB) GetProxyCacheEntry

func (m *BaseMockDB) GetProxyCacheEntry(ctx context.Context, repoID, cacheKey string) (*models.ProxyCacheEntry, error)

func (*BaseMockDB) GetPyPIPackage

func (m *BaseMockDB) GetPyPIPackage(ctx context.Context, repoID, name, version, filename string) (*models.PyPIPackage, error)

func (*BaseMockDB) GetRPMRepo

func (m *BaseMockDB) GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)

func (*BaseMockDB) GetRawArtifact

func (m *BaseMockDB) GetRawArtifact(ctx context.Context, repoID, path string) (*models.RawArtifact, error)

func (*BaseMockDB) GetReleaseBundle

func (m *BaseMockDB) GetReleaseBundle(ctx context.Context, name, version string) (*models.ReleaseBundle, error)

func (*BaseMockDB) GetReleaseBundleByID

func (m *BaseMockDB) GetReleaseBundleByID(ctx context.Context, id string) (*models.ReleaseBundle, error)

func (*BaseMockDB) GetRepoComponentBlob added in v0.3.0

func (m *BaseMockDB) GetRepoComponentBlob(ctx context.Context, repoID, id string) (*models.ComponentBlob, error)

func (*BaseMockDB) GetRepoMetadataByPath

func (m *BaseMockDB) GetRepoMetadataByPath(ctx context.Context, repositoryID string, path string) (*models.RepoMetadata, error)

func (*BaseMockDB) GetRepoMetadataByRepo

func (m *BaseMockDB) GetRepoMetadataByRepo(ctx context.Context, repositoryID string) ([]models.RepoMetadata, error)

func (*BaseMockDB) GetRepositoryByID

func (m *BaseMockDB) GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)

func (*BaseMockDB) GetRepositoryByName

func (m *BaseMockDB) GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)

func (*BaseMockDB) GetRpmPackageByID

func (m *BaseMockDB) GetRpmPackageByID(ctx context.Context, id string) (*models.RpmPackage, error)

func (*BaseMockDB) GetRubyGem

func (m *BaseMockDB) GetRubyGem(ctx context.Context, repoID, name, version, platform string) (*models.RubyGem, error)

func (*BaseMockDB) GetSBOMReport

func (m *BaseMockDB) GetSBOMReport(ctx context.Context, repoID, artifactID, format, specVersion string) (*models.SBOMReport, error)

func (*BaseMockDB) GetSBOMReportByID added in v0.2.0

func (m *BaseMockDB) GetSBOMReportByID(ctx context.Context, repoID, id string) (*models.SBOMReport, error)

func (*BaseMockDB) GetSBTArtifact

func (m *BaseMockDB) GetSBTArtifact(ctx context.Context, repoID, groupID, artifactID, version, filename string) (*models.SBTArtifact, error)

func (*BaseMockDB) GetSSOProviderByID

func (m *BaseMockDB) GetSSOProviderByID(ctx context.Context, id string) (*models.SSOProvider, error)

func (*BaseMockDB) GetSSOProviderBySlug

func (m *BaseMockDB) GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)

func (*BaseMockDB) GetSecretScanResult

func (m *BaseMockDB) GetSecretScanResult(ctx context.Context, repoID, artifactID string) (*models.SecretScanResult, error)

func (*BaseMockDB) GetSessionByTokenHash

func (m *BaseMockDB) GetSessionByTokenHash(ctx context.Context, hash string) (*models.Session, error)

func (*BaseMockDB) GetStorageBackend

func (m *BaseMockDB) GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)

func (*BaseMockDB) GetSystemSetting

func (m *BaseMockDB) GetSystemSetting(ctx context.Context, key string) (string, error)

func (*BaseMockDB) GetTokenByHash

func (m *BaseMockDB) GetTokenByHash(ctx context.Context, hash string) (*models.Token, error)

func (*BaseMockDB) GetTokenByID

func (m *BaseMockDB) GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)

func (*BaseMockDB) GetUserByEmail

func (m *BaseMockDB) GetUserByEmail(ctx context.Context, email string) (*models.User, error)

func (*BaseMockDB) GetUserByExternalID

func (m *BaseMockDB) GetUserByExternalID(ctx context.Context, externalID, providerSlug string) (*models.User, error)

func (*BaseMockDB) GetUserByID

func (m *BaseMockDB) GetUserByID(ctx context.Context, id string) (*models.User, error)

func (*BaseMockDB) GetUserByUsername

func (m *BaseMockDB) GetUserByUsername(ctx context.Context, username string) (*models.User, error)

func (*BaseMockDB) GetVulnScanResult

func (m *BaseMockDB) GetVulnScanResult(ctx context.Context, repoID, artifactID string) (*models.VulnScanResult, error)

func (*BaseMockDB) GetVulnScanResultByID added in v0.2.0

func (m *BaseMockDB) GetVulnScanResultByID(ctx context.Context, repoID, id string) (*models.VulnScanResult, error)

func (*BaseMockDB) GetWebhook

func (m *BaseMockDB) GetWebhook(ctx context.Context, id string) (*models.Webhook, error)

func (*BaseMockDB) IncrementCargoDownloadCount

func (m *BaseMockDB) IncrementCargoDownloadCount(ctx context.Context, repoID, name, version string) error

func (*BaseMockDB) IncrementNuGetDownloadCount

func (m *BaseMockDB) IncrementNuGetDownloadCount(ctx context.Context, repoID, packageID, version string) error

func (*BaseMockDB) IncrementStorageUsage

func (m *BaseMockDB) IncrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error

func (*BaseMockDB) InsertAuditLog

func (m *BaseMockDB) InsertAuditLog(ctx context.Context, event *models.AuditLog) error

func (*BaseMockDB) ListAIAnalyses

func (m *BaseMockDB) ListAIAnalyses(ctx context.Context, repoID string, status string, limit, offset int) ([]*models.AIAnalysis, int, error)

func (*BaseMockDB) ListAllCondaPackages

func (m *BaseMockDB) ListAllCondaPackages(ctx context.Context, repoID string) ([]*models.CondaPackage, error)

func (*BaseMockDB) ListAllNPMPackages

func (m *BaseMockDB) ListAllNPMPackages(ctx context.Context, repoID string) ([]*models.NPMPackage, error)

func (*BaseMockDB) ListAllSSOProviders

func (m *BaseMockDB) ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)

func (*BaseMockDB) ListAllTokens

func (m *BaseMockDB) ListAllTokens(ctx context.Context, page, perPage int) ([]*models.Token, int, error)

func (*BaseMockDB) ListArtifactProperties

func (m *BaseMockDB) ListArtifactProperties(ctx context.Context, repoID, artifactID string) (map[string]string, error)

func (*BaseMockDB) ListAuditLogs

func (m *BaseMockDB) ListAuditLogs(ctx context.Context, params models.AuditListParams) (*models.AuditPage, error)

func (*BaseMockDB) ListBackupJobs

func (m *BaseMockDB) ListBackupJobs(ctx context.Context, limit int) ([]*models.BackupJob, error)

func (*BaseMockDB) ListBundleItems

func (m *BaseMockDB) ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)

func (*BaseMockDB) ListBundlePromotions

func (m *BaseMockDB) ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)

func (*BaseMockDB) ListCargoCrateVersions

func (m *BaseMockDB) ListCargoCrateVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)

func (*BaseMockDB) ListCleanupPolicies

func (m *BaseMockDB) ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)

func (*BaseMockDB) ListComponentsByRepo

func (m *BaseMockDB) ListComponentsByRepo(ctx context.Context, repoID, formatFilter string, page, limit int) ([]*models.Component, int, error)

func (*BaseMockDB) ListConanPackages

func (m *BaseMockDB) ListConanPackages(ctx context.Context, repoID string) ([]*models.ConanPackage, error)

func (*BaseMockDB) ListCondaPackages

func (m *BaseMockDB) ListCondaPackages(ctx context.Context, repoID, platform string) ([]*models.CondaPackage, error)

func (*BaseMockDB) ListDebPackageEntries added in v0.2.0

func (m *BaseMockDB) ListDebPackageEntries(ctx context.Context, repoID, dist, comp, arch string) ([]models.DebPackageEntry, error)

func (*BaseMockDB) ListDebPackagesByRepo

func (m *BaseMockDB) ListDebPackagesByRepo(ctx context.Context, repoID string) ([]*models.DebPackage, error)

func (*BaseMockDB) ListDockerBlobs

func (m *BaseMockDB) ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)

func (*BaseMockDB) ListDockerManifestsByRepo

func (m *BaseMockDB) ListDockerManifestsByRepo(ctx context.Context, repoID string) ([]*models.DockerManifest, error)

func (*BaseMockDB) ListDockerManifestsBySubject

func (m *BaseMockDB) ListDockerManifestsBySubject(ctx context.Context, repoID, image, subjectDigest string) ([]*models.DockerManifest, error)

func (*BaseMockDB) ListDockerTags

func (m *BaseMockDB) ListDockerTags(ctx context.Context, repoID, image, last string, n int) ([]*models.DockerTag, error)

func (*BaseMockDB) ListDockerTagsByRepo added in v0.4.0

func (m *BaseMockDB) ListDockerTagsByRepo(ctx context.Context, repoID string, limit int) ([]*models.DockerTag, error)

func (*BaseMockDB) ListEnabledCleanupPolicies

func (m *BaseMockDB) ListEnabledCleanupPolicies(ctx context.Context) ([]*models.CleanupPolicy, error)

func (*BaseMockDB) ListEnabledSSOProviders

func (m *BaseMockDB) ListEnabledSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)

func (*BaseMockDB) ListGlobalLicensePolicies added in v0.2.0

func (m *BaseMockDB) ListGlobalLicensePolicies(ctx context.Context) ([]*models.LicensePolicy, error)

func (*BaseMockDB) ListGoModuleVersions

func (m *BaseMockDB) ListGoModuleVersions(ctx context.Context, repoID, modulePath string) ([]*models.GoModule, error)

func (*BaseMockDB) ListGoModulesByRepo

func (m *BaseMockDB) ListGoModulesByRepo(ctx context.Context, repoID string) ([]*models.GoModule, error)

func (*BaseMockDB) ListGroupMembers

func (m *BaseMockDB) ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)

func (*BaseMockDB) ListGroups

func (m *BaseMockDB) ListGroups(ctx context.Context) ([]*models.Group, error)

func (*BaseMockDB) ListGroupsByUser

func (m *BaseMockDB) ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)

func (*BaseMockDB) ListHelmChartVersions

func (m *BaseMockDB) ListHelmChartVersions(ctx context.Context, repoID, name string) ([]*models.HelmChart, error)

func (*BaseMockDB) ListHelmCharts

func (m *BaseMockDB) ListHelmCharts(ctx context.Context, repoID string) ([]*models.HelmChart, error)

func (*BaseMockDB) ListIvyArtifacts

func (m *BaseMockDB) ListIvyArtifacts(ctx context.Context, repoID string) ([]*models.IvyArtifact, error)

func (*BaseMockDB) ListLicensePolicies

func (m *BaseMockDB) ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)

ListLicensePolicies reports no policies: every upload that declares a license reads them (licensepolicy.Enforce), so an unconfigured mock must not fail those uploads. Tests of policy behavior override it.

func (*BaseMockDB) ListLicenseScanResults

func (m *BaseMockDB) ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)

func (*BaseMockDB) ListMavenArtifactsByRepo

func (m *BaseMockDB) ListMavenArtifactsByRepo(ctx context.Context, repoID string) ([]*models.MavenArtifact, error)

func (*BaseMockDB) ListNPMVersionsByRepo

func (m *BaseMockDB) ListNPMVersionsByRepo(ctx context.Context, repoID string) ([]*models.NPMVersion, error)

func (*BaseMockDB) ListNuGetPackageVersions

func (m *BaseMockDB) ListNuGetPackageVersions(ctx context.Context, repoID, packageID string) ([]*models.NuGetPackage, error)

func (*BaseMockDB) ListNuGetPackages

func (m *BaseMockDB) ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)

func (*BaseMockDB) ListOrgGrantsByUser added in v0.4.0

func (m *BaseMockDB) ListOrgGrantsByUser(ctx context.Context, userID string) ([]*models.OrgGrant, error)

ListOrgGrantsByUser reports no memberships: the evaluator consults it for every request a permission target did not already allow.

func (*BaseMockDB) ListOrgMembers

func (m *BaseMockDB) ListOrgMembers(ctx context.Context, orgID string) ([]*models.OrgMember, error)

func (*BaseMockDB) ListOrganizations

func (m *BaseMockDB) ListOrganizations(ctx context.Context, userID string) ([]*models.Organization, error)

func (*BaseMockDB) ListPackageDeltas

func (m *BaseMockDB) ListPackageDeltas(ctx context.Context, repoID, toSHA256 string) ([]*models.PackageDelta, error)

func (*BaseMockDB) ListPendingAIAnalyses

func (m *BaseMockDB) ListPendingAIAnalyses(ctx context.Context, limit int) ([]*models.AIAnalysis, error)

func (*BaseMockDB) ListPermissionTargets

func (m *BaseMockDB) ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)

func (*BaseMockDB) ListPromotionPipelines

func (m *BaseMockDB) ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)

func (*BaseMockDB) ListPublicRepositoryNames added in v0.3.0

func (m *BaseMockDB) ListPublicRepositoryNames(ctx context.Context) ([]string, error)

func (*BaseMockDB) ListPyPIPackageVersions

func (m *BaseMockDB) ListPyPIPackageVersions(ctx context.Context, repoID, name string) ([]*models.PyPIPackage, error)

func (*BaseMockDB) ListPyPIPackages

func (m *BaseMockDB) ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)

func (*BaseMockDB) ListRawArtifacts

func (m *BaseMockDB) ListRawArtifacts(ctx context.Context, repoID, prefix string) ([]*models.RawArtifact, error)

func (*BaseMockDB) ListReleaseBundles

func (m *BaseMockDB) ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)

func (*BaseMockDB) ListRepositories

func (m *BaseMockDB) ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)

func (*BaseMockDB) ListRpmPackagesByRepo

func (m *BaseMockDB) ListRpmPackagesByRepo(ctx context.Context, repoID string) ([]*models.RpmPackage, error)

func (*BaseMockDB) ListRpmPackagesForMetadata added in v0.2.0

func (m *BaseMockDB) ListRpmPackagesForMetadata(ctx context.Context, repoID string) ([]pkgrpm.Package, error)

func (*BaseMockDB) ListRubyGemVersions

func (m *BaseMockDB) ListRubyGemVersions(ctx context.Context, repoID, name string) ([]*models.RubyGem, error)

func (*BaseMockDB) ListRubyGems

func (m *BaseMockDB) ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)

func (*BaseMockDB) ListSBOMReports

func (m *BaseMockDB) ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)

func (*BaseMockDB) ListSBTArtifacts

func (m *BaseMockDB) ListSBTArtifacts(ctx context.Context, repoID string) ([]*models.SBTArtifact, error)

func (*BaseMockDB) ListSecretScanResults

func (m *BaseMockDB) ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)

func (*BaseMockDB) ListStorageBackends

func (m *BaseMockDB) ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)

func (*BaseMockDB) ListTokensByUser

func (m *BaseMockDB) ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)

func (*BaseMockDB) ListUsers

func (m *BaseMockDB) ListUsers(ctx context.Context, page, perPage int) ([]*models.User, int, error)

func (*BaseMockDB) ListUsersByGroup

func (m *BaseMockDB) ListUsersByGroup(ctx context.Context, groupID string) ([]*models.User, error)

func (*BaseMockDB) ListVulnScanResults

func (m *BaseMockDB) ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)

func (*BaseMockDB) ListWebhookDeliveries

func (m *BaseMockDB) ListWebhookDeliveries(ctx context.Context, webhookID string, limit int) ([]*models.WebhookDelivery, error)

func (*BaseMockDB) ListWebhooks

func (m *BaseMockDB) ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error)

func (*BaseMockDB) ListWebhooksForEvent

func (m *BaseMockDB) ListWebhooksForEvent(ctx context.Context, repoID, eventType string) ([]*models.Webhook, error)

func (*BaseMockDB) MarkPackumentStale

func (m *BaseMockDB) MarkPackumentStale(ctx context.Context, packageID string) error

func (*BaseMockDB) MarkRepoStale

func (m *BaseMockDB) MarkRepoStale(ctx context.Context, repositoryID string) error

func (*BaseMockDB) Migrate

func (m *BaseMockDB) Migrate(ctx context.Context) error

func (*BaseMockDB) Ping

func (m *BaseMockDB) Ping(ctx context.Context) error

func (*BaseMockDB) QuarantineArtifact

func (m *BaseMockDB) QuarantineArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

func (*BaseMockDB) QuarantineVulnArtifact

func (m *BaseMockDB) QuarantineVulnArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

func (*BaseMockDB) ReconcileAllStorageUsage added in v0.4.0

func (m *BaseMockDB) ReconcileAllStorageUsage(ctx context.Context) (int64, error)

func (*BaseMockDB) ReconcileStorageUsage added in v0.4.0

func (m *BaseMockDB) ReconcileStorageUsage(ctx context.Context, repoID string) (*models.StorageQuota, error)

func (*BaseMockDB) RemoveBundleItem

func (m *BaseMockDB) RemoveBundleItem(ctx context.Context, bundleID, sha256 string) error

func (*BaseMockDB) RemoveGroupMember

func (m *BaseMockDB) RemoveGroupMember(ctx context.Context, groupRepoID, memberRepoID string) error

func (*BaseMockDB) RemoveOrgMember

func (m *BaseMockDB) RemoveOrgMember(ctx context.Context, orgID, userID string) error

func (*BaseMockDB) RemoveUserFromGroup

func (m *BaseMockDB) RemoveUserFromGroup(ctx context.Context, userID, groupID string) error

func (*BaseMockDB) RepairBootstrapAdmin added in v0.2.0

func (m *BaseMockDB) RepairBootstrapAdmin(ctx context.Context, username string) (bool, error)

func (*BaseMockDB) ReplaceGroupMembers added in v0.2.0

func (m *BaseMockDB) ReplaceGroupMembers(ctx context.Context, groupRepoID string, memberIDs []string) error

func (*BaseMockDB) ReserveStorageUsage added in v0.2.0

func (m *BaseMockDB) ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)

func (*BaseMockDB) RevokeToken

func (m *BaseMockDB) RevokeToken(ctx context.Context, tokenID string) error

func (*BaseMockDB) RpmPackageExists added in v0.2.0

func (m *BaseMockDB) RpmPackageExists(ctx context.Context, repoID, name, version, release string, epoch int, arch string) (bool, error)

func (*BaseMockDB) SealReleaseBundle added in v0.2.0

func (m *BaseMockDB) SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time) (bool, error)

func (*BaseMockDB) SearchByProperty

func (m *BaseMockDB) SearchByProperty(ctx context.Context, repoID, key, value string) ([]string, error)

func (*BaseMockDB) SearchCargoCrates

func (m *BaseMockDB) SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)

func (*BaseMockDB) SearchNuGetPackages

func (m *BaseMockDB) SearchNuGetPackages(ctx context.Context, repoID, query string, skip, take int) ([]*models.NuGetPackage, int, error)

func (*BaseMockDB) SearchRubyGems

func (m *BaseMockDB) SearchRubyGems(ctx context.Context, repoID, query string) ([]*models.RubyGem, error)

func (*BaseMockDB) SetArtifactProperties added in v0.2.0

func (m *BaseMockDB) SetArtifactProperties(ctx context.Context, repoID, artifactID string, props map[string]string, replace bool) error

func (*BaseMockDB) SetArtifactProperty

func (m *BaseMockDB) SetArtifactProperty(ctx context.Context, repoID, artifactID, key, value string) error

func (*BaseMockDB) SetDebControlFields added in v0.2.0

func (m *BaseMockDB) SetDebControlFields(ctx context.Context, packageID, maintainer, homepage string, fields map[string]string) error

func (*BaseMockDB) SetLicenseScanQuarantine added in v0.4.0

func (m *BaseMockDB) SetLicenseScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error

func (*BaseMockDB) SetSystemSetting

func (m *BaseMockDB) SetSystemSetting(ctx context.Context, key, value string) error

func (*BaseMockDB) SetVulnScanQuarantine added in v0.2.0

func (m *BaseMockDB) SetVulnScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error

func (*BaseMockDB) SyncSSOGroups

func (m *BaseMockDB) SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error

func (*BaseMockDB) SyncSSOPermissionsForGroup

func (m *BaseMockDB) SyncSSOPermissionsForGroup(ctx context.Context, groupID string, targetIDs []string) error

func (*BaseMockDB) UpdateBackupJob

func (m *BaseMockDB) UpdateBackupJob(ctx context.Context, job *models.BackupJob) error

func (*BaseMockDB) UpdateBundlePromotion

func (m *BaseMockDB) UpdateBundlePromotion(ctx context.Context, p *models.BundlePromotion) error

func (*BaseMockDB) UpdateCleanupPolicy

func (m *BaseMockDB) UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error

func (*BaseMockDB) UpdateCleanupPolicyRunResult

func (m *BaseMockDB) UpdateCleanupPolicyRunResult(ctx context.Context, id string, deletedCount int, runErr error) error

func (*BaseMockDB) UpdateDockerUploadOffset

func (m *BaseMockDB) UpdateDockerUploadOffset(ctx context.Context, repositoryID, uploadUUID string, offset int64) error

func (*BaseMockDB) UpdateGroup

func (m *BaseMockDB) UpdateGroup(ctx context.Context, group *models.Group) error

func (*BaseMockDB) UpdateLicensePolicy

func (m *BaseMockDB) UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error

func (*BaseMockDB) UpdateLicenseScanResult

func (m *BaseMockDB) UpdateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error

func (*BaseMockDB) UpdateNPMPackageLatestVersion

func (m *BaseMockDB) UpdateNPMPackageLatestVersion(ctx context.Context, packageID, latestVersion string) error

func (*BaseMockDB) UpdateOrgMemberRole

func (m *BaseMockDB) UpdateOrgMemberRole(ctx context.Context, orgID, userID, role string) error

func (*BaseMockDB) UpdateOrganization

func (m *BaseMockDB) UpdateOrganization(ctx context.Context, org *models.Organization) error

func (*BaseMockDB) UpdatePermissionTarget

func (m *BaseMockDB) UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error

func (*BaseMockDB) UpdatePromotionPipeline

func (m *BaseMockDB) UpdatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error

func (*BaseMockDB) UpdateReleaseBundle

func (m *BaseMockDB) UpdateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error

func (*BaseMockDB) UpdateRepository

func (m *BaseMockDB) UpdateRepository(ctx context.Context, repo *models.Repository) error

func (*BaseMockDB) UpdateRpmPackageExtra added in v0.4.0

func (m *BaseMockDB) UpdateRpmPackageExtra(ctx context.Context, repoID, sha256 string, extra []byte) error

func (*BaseMockDB) UpdateSSOProvider

func (m *BaseMockDB) UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error

func (*BaseMockDB) UpdateSecretScanResult

func (m *BaseMockDB) UpdateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error

func (*BaseMockDB) UpdateSessionLastSeen

func (m *BaseMockDB) UpdateSessionLastSeen(ctx context.Context, sessionID string, expiresAt time.Time) error

func (*BaseMockDB) UpdateStorageBackend

func (m *BaseMockDB) UpdateStorageBackend(ctx context.Context, backend *models.StorageBackend) error

func (*BaseMockDB) UpdateStorageBackendStatus

func (m *BaseMockDB) UpdateStorageBackendStatus(ctx context.Context, id, status string, message *string) error

func (*BaseMockDB) UpdateStorageQuota

func (m *BaseMockDB) UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error

func (*BaseMockDB) UpdateTokenLastUsed

func (m *BaseMockDB) UpdateTokenLastUsed(ctx context.Context, tokenID string) error

func (*BaseMockDB) UpdateUser

func (m *BaseMockDB) UpdateUser(ctx context.Context, user *models.User) error

func (*BaseMockDB) UpdateUserSSO

func (m *BaseMockDB) UpdateUserSSO(ctx context.Context, userID string, externalID, providerSlug string) error

func (*BaseMockDB) UpdateVulnScanResult

func (m *BaseMockDB) UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error

func (*BaseMockDB) UpdateWebhook

func (m *BaseMockDB) UpdateWebhook(ctx context.Context, wh *models.Webhook) error

func (*BaseMockDB) UpdateWebhookDelivery

func (m *BaseMockDB) UpdateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error

func (*BaseMockDB) UpsertAIAnalysis

func (m *BaseMockDB) UpsertAIAnalysis(ctx context.Context, analysis *models.AIAnalysis) error

func (*BaseMockDB) UpsertBlob

func (m *BaseMockDB) UpsertBlob(ctx context.Context, sha256, blobKey string, sizeBytes int64) (string, error)

func (*BaseMockDB) UpsertDockerTag

func (m *BaseMockDB) UpsertDockerTag(ctx context.Context, tag *models.DockerTag) error

func (*BaseMockDB) UpsertNPMDistTag

func (m *BaseMockDB) UpsertNPMDistTag(ctx context.Context, t *models.NPMDistTag) (*models.NPMDistTag, error)

func (*BaseMockDB) UpsertProxyCacheEntry

func (m *BaseMockDB) UpsertProxyCacheEntry(ctx context.Context, entry *models.ProxyCacheEntry) error

func (*BaseMockDB) UpsertRawArtifact

func (m *BaseMockDB) UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error

func (*BaseMockDB) UpsertRepoMetadata

func (m *BaseMockDB) UpsertRepoMetadata(ctx context.Context, meta *models.RepoMetadata) error

func (*BaseMockDB) YankCargoCrate

func (m *BaseMockDB) YankCargoCrate(ctx context.Context, repoID, name, version string, yanked bool) error

func (*BaseMockDB) YankRubyGem

func (m *BaseMockDB) YankRubyGem(ctx context.Context, repoID, name, version string, yanked bool) error

type Database

type Database interface {
	// GetDB returns the underlying sql.DB connection
	GetDB() *sql.DB

	// Close closes the database connection
	Close() error

	// Ping checks if the database is accessible
	Ping(ctx context.Context) error

	// BeginTx starts a new transaction
	BeginTx(ctx context.Context) (Transaction, error)

	// Migrate runs database migrations
	Migrate(ctx context.Context) error

	GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
	GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
	CreateRepository(ctx context.Context, repo *models.Repository) error
	// ListPublicRepositoryNames returns the names of all repositories flagged public.
	ListPublicRepositoryNames(ctx context.Context) ([]string, error)
	ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)
	CountRepositories(ctx context.Context, formatFilter string) (int, error)
	UpdateRepository(ctx context.Context, repo *models.Repository) error
	DeleteRepository(ctx context.Context, id string) error
	ListComponentsByRepo(ctx context.Context, repoID, formatFilter string, page, limit int) ([]*models.Component, int, error)

	GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)
	CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error
	MarkRepoStale(ctx context.Context, repositoryID string) error

	CreateComponent(ctx context.Context, component *models.Component) error
	CreateDebPackage(ctx context.Context, pkg *models.Component, distID, compID string) error
	CreateRpmPackage(ctx context.Context, pkg *models.Component) error
	UpsertBlob(ctx context.Context, sha256, blobKey string, sizeBytes int64) (string, error)
	GetComponentByID(ctx context.Context, id string) (*models.Component, error)
	// GetRepoComponentBlob resolves a package-listing row id (any format) to its
	// blob, scoped to repoID. Returns nil, nil when the id is not in that repository.
	GetRepoComponentBlob(ctx context.Context, repoID, id string) (*models.ComponentBlob, error)
	GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
	GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)
	DeleteComponent(ctx context.Context, componentID string) error

	GetRepoMetadataByPath(ctx context.Context, repositoryID string, path string) (*models.RepoMetadata, error)
	GetRepoMetadataByRepo(ctx context.Context, repositoryID string) ([]models.RepoMetadata, error)
	UpsertRepoMetadata(ctx context.Context, meta *models.RepoMetadata) error

	CreateDebianDistribution(ctx context.Context, dist *models.DebianDistribution) error
	GetDebianDistribution(ctx context.Context, repoID string, name string) (*models.DebianDistribution, error)
	GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)
	CreateDebianComponent(ctx context.Context, comp *models.DebianComponent) error
	GetDebianComponentsByDist(ctx context.Context, distID string) ([]models.DebianComponent, error)
	CreateDebianArchitecture(ctx context.Context, arch *models.DebianArchitecture) error
	GetDebianArchitecturesByDist(ctx context.Context, distID string) ([]models.DebianArchitecture, error)
	GetDebianPackageByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
	GetDebianPackagesByDistComp(ctx context.Context, repoID string, dist string, comp string, arch string) ([]models.Component, error)
	GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)
	ListDebPackagesByRepo(ctx context.Context, repoID string) ([]*models.DebPackage, error)
	GetOrCreateDebianDistribution(ctx context.Context, repoID, name string) (*models.DebianDistribution, error)
	GetOrCreateDebianComponent(ctx context.Context, distID, name string) (*models.DebianComponent, error)
	GetOrCreateDebianArchitecture(ctx context.Context, distID, name string) (*models.DebianArchitecture, error)
	SetDebControlFields(ctx context.Context, packageID, maintainer, homepage string, fields map[string]string) error
	GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)
	ListDebPackageEntries(ctx context.Context, repoID, dist, comp, arch string) ([]models.DebPackageEntry, error)
	GetRpmPackageByID(ctx context.Context, id string) (*models.RpmPackage, error)
	ListRpmPackagesByRepo(ctx context.Context, repoID string) ([]*models.RpmPackage, error)
	// RpmPackageExists reports whether the repo already has a package with the given NEVRA.
	RpmPackageExists(ctx context.Context, repoID, name, version, release string, epoch int, arch string) (bool, error)
	// ListRpmPackagesForMetadata returns every rpm package of a repo with
	// dependencies, files, changelogs and header range loaded.
	ListRpmPackagesForMetadata(ctx context.Context, repoID string) ([]pkgrpm.Package, error)
	// UpdateRpmPackageExtra replaces rpm_extra for the repo's package(s) whose
	// blob has the given sha256 (used to backfill weak dependencies).
	UpdateRpmPackageExtra(ctx context.Context, repoID, sha256 string, extra []byte) error

	CreateMavenArtifact(ctx context.Context, a *models.MavenArtifact) error
	GetMavenArtifactByPath(ctx context.Context, repoID, path string) (*models.MavenArtifact, error)
	GetMavenArtifactsByGAV(ctx context.Context, repoID, groupID, artifactID, version string) ([]*models.MavenArtifact, error)
	GetMavenArtifactsByGA(ctx context.Context, repoID, groupID, artifactID string) ([]*models.MavenArtifact, error)
	GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)
	DeleteMavenArtifact(ctx context.Context, id string) error

	// ListMavenArtifactsByRepo is a bulk-list-by-repo method used only by
	// backup export (no GA/path filter required).
	ListMavenArtifactsByRepo(ctx context.Context, repoID string) ([]*models.MavenArtifact, error)

	CreateNPMPackage(ctx context.Context, p *models.NPMPackage) (*models.NPMPackage, error)
	GetNPMPackageByName(ctx context.Context, repoID, fullName string) (*models.NPMPackage, error)
	DeleteNPMPackage(ctx context.Context, packageID string) error
	MarkPackumentStale(ctx context.Context, packageID string) error
	UpdateNPMPackageLatestVersion(ctx context.Context, packageID, latestVersion string) error
	CreateNPMVersion(ctx context.Context, v *models.NPMVersion) (*models.NPMVersion, error)
	GetNPMVersion(ctx context.Context, packageID, version string) (*models.NPMVersion, error)
	GetNPMVersionsByPackage(ctx context.Context, packageID string) ([]*models.NPMVersion, error)
	DeleteNPMVersion(ctx context.Context, packageID, version string) error
	UpsertNPMDistTag(ctx context.Context, t *models.NPMDistTag) (*models.NPMDistTag, error)
	GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)
	DeleteNPMDistTag(ctx context.Context, packageID, tag string) error

	// ListAllNPMPackages/ListNPMVersionsByRepo are bulk-list-by-repo methods
	// used only by backup export (no name/GA/platform filter required).
	ListAllNPMPackages(ctx context.Context, repoID string) ([]*models.NPMPackage, error)
	ListNPMVersionsByRepo(ctx context.Context, repoID string) ([]*models.NPMVersion, error)

	// Docker Registry methods
	CreateDockerBlob(ctx context.Context, blob *models.DockerBlob) error
	GetDockerBlob(ctx context.Context, repoID, digest string) (*models.DockerBlob, error)
	DeleteDockerBlob(ctx context.Context, repoID, digest string) error
	ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)

	CreateDockerUpload(ctx context.Context, upload *models.DockerUpload) error
	GetDockerUpload(ctx context.Context, repositoryID, uploadUUID string) (*models.DockerUpload, error)
	UpdateDockerUploadOffset(ctx context.Context, repositoryID, uploadUUID string, offset int64) error
	DeleteDockerUpload(ctx context.Context, repositoryID, uploadUUID string) error

	CreateDockerManifest(ctx context.Context, m *models.DockerManifest) error
	GetDockerManifest(ctx context.Context, repoID, image, digest string) (*models.DockerManifest, error)
	DeleteDockerManifest(ctx context.Context, repoID, image, digest string) error

	// ListDockerManifestsByRepo is a bulk-list-by-repo method used only by
	// backup export (no digest/subject filter required).
	ListDockerManifestsByRepo(ctx context.Context, repoID string) ([]*models.DockerManifest, error)

	UpsertDockerTag(ctx context.Context, tag *models.DockerTag) error
	GetDockerTag(ctx context.Context, repoID, image, name string) (*models.DockerTag, error)
	DeleteDockerTag(ctx context.Context, repoID, image, name string) error
	// DeleteDockerTagsByDigest removes every tag of the image that points at digest.
	DeleteDockerTagsByDigest(ctx context.Context, repoID, image, digest string) error
	ListDockerTags(ctx context.Context, repoID, image, last string, n int) ([]*models.DockerTag, error)
	// ListDockerTagsByRepo lists up to limit tags across every image of the repository (backup export).
	ListDockerTagsByRepo(ctx context.Context, repoID string, limit int) ([]*models.DockerTag, error)

	// EnsureBlob ensures the global blobs table has a row for sha256
	// (creating it, or updating its media type, if needed) and returns its
	// blobs.id. Used by manifest handlers that need a blob_id FK without an
	// accompanying per-format registry row (unlike UpsertBlob's callers).
	EnsureBlob(ctx context.Context, sha256, mediaType string, size int64) (string, error)

	// ListDockerManifestsBySubject returns manifests in repoID whose OCI
	// `subject` field points at subjectDigest, for the Referrers API.
	ListDockerManifestsBySubject(ctx context.Context, repoID, image, subjectDigest string) ([]*models.DockerManifest, error)

	// Proxy/Group repository methods
	AddGroupMember(ctx context.Context, groupRepoID, memberRepoID string, priority int) error
	RemoveGroupMember(ctx context.Context, groupRepoID, memberRepoID string) error
	ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
	// ReplaceGroupMembers atomically replaces a group's ordered member list (empty clears it).
	ReplaceGroupMembers(ctx context.Context, groupRepoID string, memberIDs []string) error
	// CreateRepositoryWithMembers creates a repository and its group members in one transaction.
	CreateRepositoryWithMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
	GetProxyCacheEntry(ctx context.Context, repoID, cacheKey string) (*models.ProxyCacheEntry, error)
	UpsertProxyCacheEntry(ctx context.Context, entry *models.ProxyCacheEntry) error
	DeleteProxyCacheEntry(ctx context.Context, repoID, cacheKey string) error
	DeleteExpiredProxyCacheEntries(ctx context.Context) (int64, error)

	// Helm methods
	CreateHelmChart(ctx context.Context, chart *models.HelmChart) error
	GetHelmChart(ctx context.Context, repoID, name, version string) (*models.HelmChart, error)
	DeleteHelmChart(ctx context.Context, repoID, name, version string) error
	ListHelmCharts(ctx context.Context, repoID string) ([]*models.HelmChart, error)
	ListHelmChartVersions(ctx context.Context, repoID, name string) ([]*models.HelmChart, error)

	// PyPI methods
	CreatePyPIPackage(ctx context.Context, pkg *models.PyPIPackage) error
	GetPyPIPackage(ctx context.Context, repoID, name, version, filename string) (*models.PyPIPackage, error)
	DeletePyPIPackage(ctx context.Context, repoID, name, version, filename string) error
	ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)
	ListPyPIPackageVersions(ctx context.Context, repoID, name string) ([]*models.PyPIPackage, error)

	// NuGet methods
	CreateNuGetPackage(ctx context.Context, pkg *models.NuGetPackage) error
	GetNuGetPackage(ctx context.Context, repoID, packageID, version string) (*models.NuGetPackage, error)
	DeleteNuGetPackage(ctx context.Context, repoID, packageID, version string) error
	ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)
	ListNuGetPackageVersions(ctx context.Context, repoID, packageID string) ([]*models.NuGetPackage, error)
	SearchNuGetPackages(ctx context.Context, repoID, query string, skip, take int) ([]*models.NuGetPackage, int, error)
	IncrementNuGetDownloadCount(ctx context.Context, repoID, packageID, version string) error

	CreateUser(ctx context.Context, user *models.User) (*models.User, error)
	GetUserByID(ctx context.Context, id string) (*models.User, error)
	GetUserByUsername(ctx context.Context, username string) (*models.User, error)
	UpdateUser(ctx context.Context, user *models.User) error
	ListUsers(ctx context.Context, page, perPage int) ([]*models.User, int, error)
	CountUsers(ctx context.Context) (int, error)
	// CreateBootstrapAdmin atomically (advisory-locked transaction) creates the first
	// admin user and binds it to the admin-all permission target. It reports false
	// without creating anything when another replica already created a user.
	CreateBootstrapAdmin(ctx context.Context, username, passwordHash string) (bool, error)
	// RepairBootstrapAdmin re-binds the bootstrap admin to admin-all when no principal
	// holds that target (a previously interrupted bootstrap). Reports whether it repaired.
	RepairBootstrapAdmin(ctx context.Context, username string) (bool, error)

	CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)
	GetGroupByID(ctx context.Context, id string) (*models.Group, error)
	UpdateGroup(ctx context.Context, group *models.Group) error
	DeleteGroup(ctx context.Context, id string) error
	ListGroups(ctx context.Context) ([]*models.Group, error)
	AddUserToGroup(ctx context.Context, userID, groupID string) error
	RemoveUserFromGroup(ctx context.Context, userID, groupID string) error
	ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)
	ListUsersByGroup(ctx context.Context, groupID string) ([]*models.User, error)

	CreateSession(ctx context.Context, session *models.Session) (*models.Session, error)
	GetSessionByTokenHash(ctx context.Context, hash string) (*models.Session, error)
	DeleteSession(ctx context.Context, tokenHash string) error
	UpdateSessionLastSeen(ctx context.Context, sessionID string, expiresAt time.Time) error
	// ConsumeSAMLAssertion records a SAML assertion ID as used; false means it was
	// already consumed (replay).
	ConsumeSAMLAssertion(ctx context.Context, providerSlug, assertionID string, expiresAt time.Time) (bool, error)
	// DeleteSessionsByUser revokes every session of a user (password change/reset, disable).
	DeleteSessionsByUser(ctx context.Context, userID string) error
	// DeleteOtherSessionsByUser revokes every session of a user except the one whose
	// token hash is keepTokenHash (used on self-service password change).
	DeleteOtherSessionsByUser(ctx context.Context, userID, keepTokenHash string) error

	CreateToken(ctx context.Context, token *models.Token) (*models.Token, error)
	GetTokenByHash(ctx context.Context, hash string) (*models.Token, error)
	GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)
	RevokeToken(ctx context.Context, tokenID string) error
	UpdateTokenLastUsed(ctx context.Context, tokenID string) error
	ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)

	CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)
	GetPermissionTargetByID(ctx context.Context, id string) (*models.PermissionTarget, error)
	GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
	UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error
	DeletePermissionTarget(ctx context.Context, id string) error
	ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)
	CreatePermissionAssignment(ctx context.Context, assignment *models.PermissionAssignment) error
	DeletePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error
	GetPermissionTargetsForPrincipal(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)
	GetOrCreatePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error
	SyncSSOPermissionsForGroup(ctx context.Context, groupID string, targetIDs []string) error

	CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
	GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)
	GetSSOProviderByID(ctx context.Context, id string) (*models.SSOProvider, error)
	UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
	DeleteSSOProvider(ctx context.Context, id string) error
	ListEnabledSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
	ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
	UpdateUserSSO(ctx context.Context, userID string, externalID, providerSlug string) error
	SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error
	GetUserByExternalID(ctx context.Context, externalID, providerSlug string) (*models.User, error)
	GetUserByEmail(ctx context.Context, email string) (*models.User, error)
	GetGroupByName(ctx context.Context, name string) (*models.Group, error)
	GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)

	ArtifactExists(ctx context.Context, sha256 string, repositoryID string) (bool, error)

	// ArtifactExistsBySHA256 checks whether a blob with the given SHA-256 hash exists
	// in ANY repository. Returns the repository ID of the first match and true if found.
	// Use this for cross-repository deduplication: if the blob is already stored,
	// the upload pipeline can skip re-uploading it to the blob store.
	ArtifactExistsBySHA256(ctx context.Context, sha256 string) (repositoryID string, exists bool, err error)

	// BlobReferenceCount returns the number of package-table rows referencing
	// the blob identified by sha256, across every format table that stores a
	// blob_id FK into the global blobs table. 0 means the blob is a GC
	// candidate. Use SafeDeleteBlob (internal/storage/refcount.go) instead of
	// calling blobStore.Delete directly.
	BlobReferenceCount(ctx context.Context, sha256 string) (int, error)

	// Go Module Proxy methods
	CreateGoModule(ctx context.Context, mod *models.GoModule) error
	GetGoModule(ctx context.Context, repoID, modulePath, version string) (*models.GoModule, error)
	DeleteGoModule(ctx context.Context, repoID, modulePath, version string) error
	ListGoModuleVersions(ctx context.Context, repoID, modulePath string) ([]*models.GoModule, error)
	GetLatestGoModule(ctx context.Context, repoID, modulePath string) (*models.GoModule, error)

	// ListGoModulesByRepo is a bulk-list-by-repo method used only by backup
	// export (no module path filter required).
	ListGoModulesByRepo(ctx context.Context, repoID string) ([]*models.GoModule, error)

	InsertAuditLog(ctx context.Context, event *models.AuditLog) error
	ListAuditLogs(ctx context.Context, params models.AuditListParams) (*models.AuditPage, error)
	ListAllTokens(ctx context.Context, page, perPage int) ([]*models.Token, int, error)

	// Cleanup policy methods
	CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
	GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)
	UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
	DeleteCleanupPolicy(ctx context.Context, id string) error
	ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)
	ListEnabledCleanupPolicies(ctx context.Context) ([]*models.CleanupPolicy, error)
	UpdateCleanupPolicyRunResult(ctx context.Context, id string, deletedCount int, runErr error) error

	// Webhook methods
	CreateWebhook(ctx context.Context, wh *models.Webhook) error
	GetWebhook(ctx context.Context, id string) (*models.Webhook, error)
	UpdateWebhook(ctx context.Context, wh *models.Webhook) error
	DeleteWebhook(ctx context.Context, id string) error
	ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error) // repoID="" = global
	ListWebhooksForEvent(ctx context.Context, repoID, eventType string) ([]*models.Webhook, error)
	CreateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error
	UpdateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error
	ListWebhookDeliveries(ctx context.Context, webhookID string, limit int) ([]*models.WebhookDelivery, error)
	// ClaimPendingWebhookDeliveries atomically leases up to limit due deliveries
	// (FOR UPDATE SKIP LOCKED) so several server instances never share a row.
	ClaimPendingWebhookDeliveries(ctx context.Context, limit int, lease time.Duration) ([]*models.WebhookDelivery, error)

	// Backup methods
	CreateBackupJob(ctx context.Context, job *models.BackupJob) error
	GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)
	UpdateBackupJob(ctx context.Context, job *models.BackupJob) error
	ListBackupJobs(ctx context.Context, limit int) ([]*models.BackupJob, error)

	// Cargo methods
	CreateCargoCrate(ctx context.Context, crate *models.CargoCrate) error
	GetCargoCrate(ctx context.Context, repoID, name, version string) (*models.CargoCrate, error)
	DeleteCargoCrate(ctx context.Context, id string) error
	ListCargoCrateVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)
	SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)
	YankCargoCrate(ctx context.Context, repoID, name, version string, yanked bool) error
	IncrementCargoDownloadCount(ctx context.Context, repoID, name, version string) error

	// RubyGems methods
	CreateRubyGem(ctx context.Context, gem *models.RubyGem) error
	GetRubyGem(ctx context.Context, repoID, name, version, platform string) (*models.RubyGem, error)
	DeleteRubyGem(ctx context.Context, id string) error
	ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)
	ListRubyGemVersions(ctx context.Context, repoID, name string) ([]*models.RubyGem, error)
	SearchRubyGems(ctx context.Context, repoID, query string) ([]*models.RubyGem, error)
	YankRubyGem(ctx context.Context, repoID, name, version string, yanked bool) error

	// Raw artifact methods
	UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error
	GetRawArtifact(ctx context.Context, repoID, path string) (*models.RawArtifact, error)
	DeleteRawArtifact(ctx context.Context, repoID, path string) error
	ListRawArtifacts(ctx context.Context, repoID, prefix string) ([]*models.RawArtifact, error)

	// SBOM methods
	CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error
	GetSBOMReport(ctx context.Context, repoID, artifactID, format, specVersion string) (*models.SBOMReport, error)
	ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)
	DeleteSBOMReport(ctx context.Context, id string) error

	// License compliance methods
	CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
	GetLicenseScanResult(ctx context.Context, repoID, artifactID string) (*models.LicenseScanResult, error)
	UpdateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
	ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)
	CreateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
	GetLicensePolicy(ctx context.Context, id string) (*models.LicensePolicy, error)
	UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
	DeleteLicensePolicy(ctx context.Context, id string) error
	ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)

	// Secret detection methods
	CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error
	GetSecretScanResult(ctx context.Context, repoID, artifactID string) (*models.SecretScanResult, error)
	UpdateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error
	ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)
	QuarantineArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

	// Vulnerability scanning methods
	CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
	GetVulnScanResult(ctx context.Context, repoID, artifactID string) (*models.VulnScanResult, error)
	UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
	ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)
	QuarantineVulnArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

	// Storage quota methods
	GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
	UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
	IncrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
	DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
	// ReserveStorageUsage atomically adds usage if it fits the quota; false,nil when exceeded.
	ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
	// ReconcileStorageUsage recomputes one repository's usage counters from its
	// package rows (sum of blob sizes, one artifact per row) and returns the
	// corrected quota.
	ReconcileStorageUsage(ctx context.Context, repoID string) (*models.StorageQuota, error)
	// ReconcileAllStorageUsage does the same for every repository and returns how
	// many counters it had to correct. Concurrent callers (other replicas) are
	// serialized: a caller that finds a run in progress returns 0, nil.
	ReconcileAllStorageUsage(ctx context.Context) (int64, error)

	// Storage backends
	CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
	ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)
	GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)
	UpdateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
	DeleteStorageBackend(ctx context.Context, id string) error
	CountBlobsOnStorageBackend(ctx context.Context, backendID string) (int64, error)
	UpdateStorageBackendStatus(ctx context.Context, id, status string, message *string) error

	// Artifact properties methods
	SetArtifactProperty(ctx context.Context, repoID, artifactID, key, value string) error
	GetArtifactProperty(ctx context.Context, repoID, artifactID, key string) (string, error)
	DeleteArtifactProperty(ctx context.Context, repoID, artifactID, key string) error
	ListArtifactProperties(ctx context.Context, repoID, artifactID string) (map[string]string, error)
	SearchByProperty(ctx context.Context, repoID, key, value string) ([]string, error)

	// Package delta methods
	CreatePackageDelta(ctx context.Context, delta *models.PackageDelta) error
	GetPackageDelta(ctx context.Context, repoID, fromSHA256, toSHA256 string) (*models.PackageDelta, error)
	ListPackageDeltas(ctx context.Context, repoID, toSHA256 string) ([]*models.PackageDelta, error)
	DeletePackageDelta(ctx context.Context, id string) error

	// Organization methods
	CreateOrganization(ctx context.Context, org *models.Organization) error
	GetOrganization(ctx context.Context, id string) (*models.Organization, error)
	GetOrganizationByName(ctx context.Context, name string) (*models.Organization, error)
	UpdateOrganization(ctx context.Context, org *models.Organization) error
	DeleteOrganization(ctx context.Context, id string) error
	ListOrganizations(ctx context.Context, userID string) ([]*models.Organization, error)
	AddOrgMember(ctx context.Context, orgID, userID, role string) error
	RemoveOrgMember(ctx context.Context, orgID, userID string) error
	ListOrgMembers(ctx context.Context, orgID string) ([]*models.OrgMember, error)
	GetOrgMember(ctx context.Context, orgID, userID string) (*models.OrgMember, error)
	UpdateOrgMemberRole(ctx context.Context, orgID, userID, role string) error
	// ListOrgGrantsByUser returns the user's organization memberships (cached
	// like the other per-request auth lookups).
	ListOrgGrantsByUser(ctx context.Context, userID string) ([]*models.OrgGrant, error)

	// System settings methods
	GetSystemSetting(ctx context.Context, key string) (string, error)
	SetSystemSetting(ctx context.Context, key, value string) error

	// Conda methods
	CreateCondaPackage(ctx context.Context, pkg *models.CondaPackage) error
	GetCondaPackage(ctx context.Context, repoID, name, version, buildString, platform string) (*models.CondaPackage, error)
	DeleteCondaPackage(ctx context.Context, id string) error
	ListCondaPackages(ctx context.Context, repoID, platform string) ([]*models.CondaPackage, error)

	// ListAllCondaPackages is a bulk-list-by-repo method used only by backup
	// export (no platform filter required).
	ListAllCondaPackages(ctx context.Context, repoID string) ([]*models.CondaPackage, error)

	// Conan methods
	CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error
	GetConanPackage(ctx context.Context, repoID, name, version, userChannel, recipeRevision string) (*models.ConanPackage, error)
	DeleteConanPackage(ctx context.Context, id string) error
	ListConanPackages(ctx context.Context, repoID string) ([]*models.ConanPackage, error)

	// Ivy methods
	CreateIvyArtifact(ctx context.Context, artifact *models.IvyArtifact) error
	GetIvyArtifact(ctx context.Context, repoID, organisation, module, revision, artifactName, artifactExt string) (*models.IvyArtifact, error)
	DeleteIvyArtifact(ctx context.Context, id string) error
	ListIvyArtifacts(ctx context.Context, repoID string) ([]*models.IvyArtifact, error)

	// SBT methods
	CreateSBTArtifact(ctx context.Context, artifact *models.SBTArtifact) error
	GetSBTArtifact(ctx context.Context, repoID, groupID, artifactID, version, filename string) (*models.SBTArtifact, error)
	DeleteSBTArtifact(ctx context.Context, id string) error
	ListSBTArtifacts(ctx context.Context, repoID string) ([]*models.SBTArtifact, error)

	// Release bundle and promotion pipeline methods
	CreatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error
	GetPromotionPipelineByName(ctx context.Context, name string) (*models.PromotionPipeline, error)
	GetPromotionPipelineByID(ctx context.Context, id string) (*models.PromotionPipeline, error)
	UpdatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error
	DeletePromotionPipeline(ctx context.Context, id string) error
	ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)

	CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
	GetReleaseBundle(ctx context.Context, name, version string) (*models.ReleaseBundle, error)
	GetReleaseBundleByID(ctx context.Context, id string) (*models.ReleaseBundle, error)
	UpdateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
	DeleteReleaseBundle(ctx context.Context, id string) error
	ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)

	AddBundleItem(ctx context.Context, item *models.ReleaseBundleItem) error
	RemoveBundleItem(ctx context.Context, bundleID, sha256 string) error
	ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)
	GetBundleItem(ctx context.Context, bundleID, sha256 string) (*models.ReleaseBundleItem, error)

	CreateBundlePromotion(ctx context.Context, p *models.BundlePromotion) error
	UpdateBundlePromotion(ctx context.Context, p *models.BundlePromotion) error
	ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)
	// AddBundleItems atomically adds items to a draft bundle (ErrBundleNotDraft otherwise).
	AddBundleItems(ctx context.Context, bundleID string, items []*models.ReleaseBundleItem) error
	// SealReleaseBundle conditionally moves a non-empty draft bundle to sealed; false when it was not a draft.
	SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time) (bool, error)

	// Scan lookups/deletes by ID scoped to a repository (nil / not-found errors when absent).
	GetVulnScanResultByID(ctx context.Context, repoID, id string) (*models.VulnScanResult, error)
	DeleteVulnScanResult(ctx context.Context, repoID, id string) error
	SetVulnScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error
	GetLicenseScanResultByID(ctx context.Context, repoID, id string) (*models.LicenseScanResult, error)
	// SetLicenseScanQuarantine quarantines (true) or approves (false) the artifact of one license scan result.
	SetLicenseScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error
	ListGlobalLicensePolicies(ctx context.Context) ([]*models.LicensePolicy, error)
	GetSBOMReportByID(ctx context.Context, repoID, id string) (*models.SBOMReport, error)
	// DeleteSBOMReportInRepo deletes the report and returns the sha256 of its blob ("" if none).
	DeleteSBOMReportInRepo(ctx context.Context, repoID, id string) (string, error)

	// SetArtifactProperties upserts props in one transaction; replace=true clears existing ones first.
	SetArtifactProperties(ctx context.Context, repoID, artifactID string, props map[string]string, replace bool) error

	// AI analysis methods
	UpsertAIAnalysis(ctx context.Context, analysis *models.AIAnalysis) error
	GetAIAnalysis(ctx context.Context, repoID, artifactID string) (*models.AIAnalysis, error)
	ListAIAnalyses(ctx context.Context, repoID string, status string, limit, offset int) ([]*models.AIAnalysis, int, error)
	DeleteAIAnalysis(ctx context.Context, repoID, artifactID string) error
	ListPendingAIAnalyses(ctx context.Context, limit int) ([]*models.AIAnalysis, error)
}

Database defines the interface for database operations.

type DatabaseConfig

type DatabaseConfig struct {
	Driver                 string            `yaml:"driver"` // "postgres", "mysql", "sqlite"
	Host                   string            `yaml:"host"`
	Port                   int               `yaml:"port"`
	User                   string            `yaml:"user"`
	Password               string            `yaml:"password"`
	Database               string            `yaml:"database"`
	SSLMode                string            `yaml:"sslMode"` // For PostgreSQL
	Options                map[string]string `yaml:"options"`
	MaxOpenConns           int               `yaml:"maxOpenConns"`           // Maximum number of open connections (default: 25)
	MaxIdleConns           int               `yaml:"maxIdleConns"`           // Maximum number of idle connections (default: 5)
	ConnMaxLifetimeMinutes int               `yaml:"connMaxLifetimeMinutes"` // Maximum lifetime of a connection in minutes (default: 30)
	// AuthCacheTTLMillis is how long per-request authentication lookups (token,
	// user, groups, permission targets, repository by name) are served from
	// memory. Writes through this process invalidate immediately; other
	// replicas observe a change after at most this long. 0 disables the cache.
	AuthCacheTTLMillis int `yaml:"authCacheTtlMs"`
}

DatabaseConfig contains database connection configuration.

type DockerBlobToucher added in v0.4.0

type DockerBlobToucher interface {
	// TouchDockerBlob records a use of the blob and reports false when the
	// repository no longer has it.
	TouchDockerBlob(ctx context.Context, repoID, digest string) (bool, error)
}

DockerBlobToucher is implemented by databases that track when a registry blob was last used, so registry GC keeps recently used blobs.

type DockerGCStore added in v0.4.0

type DockerGCStore interface {
	// ListUnindexedDockerManifests returns up to limit manifests of the
	// repository whose references have not been recorded yet.
	ListUnindexedDockerManifests(ctx context.Context, repoID string, limit int) ([]*models.DockerGCManifest, error)

	// SetDockerManifestRefs records the references of a manifest body and marks
	// the manifest indexed. A manifest deleted meanwhile is skipped silently.
	SetDockerManifestRefs(ctx context.Context, repoID string, m *models.DockerGCManifest, refs models.DockerManifestRefs) error

	// ListDockerGCManifests returns every manifest of the repository with its
	// tagged/young flags (young: pushed within grace) and index children.
	ListDockerGCManifests(ctx context.Context, repoID string, grace time.Duration) ([]*models.DockerGCManifest, error)

	// DeleteDockerManifestsForGC deletes the given manifests (by row id) that
	// are still older than grace, untagged and not adjacent to a manifest
	// outside ids, and returns the ones actually deleted.
	DeleteDockerManifestsForGC(ctx context.Context, repoID string, ids []string, grace time.Duration) ([]*models.DockerGCManifest, error)

	// ListDockerGCBlobs returns up to limit blob records of the repository that
	// no manifest other than excludeManifestIDs references and that have not
	// been used within grace.
	ListDockerGCBlobs(ctx context.Context, repoID string, grace time.Duration, excludeManifestIDs []string, limit int) ([]*models.DockerGCBlob, error)

	// DeleteDockerBlobsForGC deletes the given blob records (by digest) that are
	// still unreferenced and unused within grace, and returns the ones actually
	// deleted. The caller removes the underlying blobs with storage.SafeDeleteBlob.
	DeleteDockerBlobsForGC(ctx context.Context, repoID string, digests []string, grace time.Duration) ([]*models.DockerGCBlob, error)

	// BlobRowExists reports whether the global blobs table still has sha256.
	BlobRowExists(ctx context.Context, sha256 string) (bool, error)
}

DockerGCStore is the storage side of Docker registry garbage collection (internal/worker.DockerGCWorker). PostgresDB implements it; the worker reports GC as unsupported for databases that do not.

Mutations take the repository's exclusive docker lock for the length of one transaction. CreateDockerManifest takes the same lock shared, so a push either completes before a GC transaction starts (and its references are then visible to it) or starts after it ends.

type MigrationStatus

type MigrationStatus struct {
	Version   string
	AppliedAt *time.Time
	Checksum  string
	Pending   bool
}

MigrationStatus describes the state of a single migration file.

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator applies embedded SQL migrations to a PostgreSQL database.

func NewMigrator

func NewMigrator(db *sql.DB) *Migrator

NewMigrator returns a Migrator backed by the embedded migrations FS.

func NewMigratorWithFS

func NewMigratorWithFS(db *sql.DB, fsys fs.ReadDirFS) *Migrator

NewMigratorWithFS returns a Migrator using a custom FS, intended for testing.

func (*Migrator) Apply

func (m *Migrator) Apply(ctx context.Context) error

Apply runs all pending migrations in lexicographic order. It is idempotent: already-applied migrations are skipped. Returns an error if any migration fails or checksum drift is detected.

func (*Migrator) Status

func (m *Migrator) Status(ctx context.Context) ([]MigrationStatus, error)

Status returns the state of every embedded migration.

type PostgresDB

type PostgresDB struct {
	// contains filtered or unexported fields
}

PostgresDB implements the Database interface for PostgreSQL.

func NewPostgresDB

func NewPostgresDB(cfg DatabaseConfig, log *logger.Logger) (*PostgresDB, error)

func (*PostgresDB) AddBundleItem

func (p *PostgresDB) AddBundleItem(ctx context.Context, item *models.ReleaseBundleItem) error

AddBundleItem inserts a bundle item. release_bundle_items has no component_id column, so item.ComponentID never round-trips through storage. The adder is stored as an adder_id UUID FK resolved from AddedBy (username) via a scalar subquery.

func (*PostgresDB) AddBundleItems added in v0.2.0

func (p *PostgresDB) AddBundleItems(ctx context.Context, bundleID string, items []*models.ReleaseBundleItem) error

AddBundleItems inserts all items atomically. The bundle row is locked and must be in draft state; otherwise ErrBundleNotDraft / ErrBundleNotFound is returned and nothing is inserted. Items whose (bundle_id, sha256) already exists are skipped. Each item's ID is filled in.

func (*PostgresDB) AddGroupMember

func (p *PostgresDB) AddGroupMember(ctx context.Context, groupRepoID, memberRepoID string, priority int) error

func (*PostgresDB) AddOrgMember

func (p *PostgresDB) AddOrgMember(ctx context.Context, orgID, userID, role string) error

func (*PostgresDB) AddUserToGroup

func (p *PostgresDB) AddUserToGroup(ctx context.Context, userID, groupID string) error

func (*PostgresDB) ArtifactExists

func (p *PostgresDB) ArtifactExists(ctx context.Context, sha256 string, repositoryID string) (bool, error)

func (*PostgresDB) ArtifactExistsBySHA256

func (p *PostgresDB) ArtifactExistsBySHA256(ctx context.Context, sha256 string) (string, bool, error)

ArtifactExistsBySHA256 checks whether a blob with the given SHA-256 hash exists in any repository. Returns the repository ID of the first match.

func (*PostgresDB) BeginTx

func (p *PostgresDB) BeginTx(ctx context.Context) (Transaction, error)

BeginTx starts a new transaction.

func (*PostgresDB) BlobReferenceCount

func (p *PostgresDB) BlobReferenceCount(ctx context.Context, sha256 string) (int, error)

BlobReferenceCount returns the number of rows, across every package table that stores a blob_id FK into the global blobs table, referencing the blob identified by sha256. A count of 0 means the blob is safe to delete from storage (see SafeDeleteBlob in internal/storage/refcount.go). A blob that does not exist in the blobs table at all is treated as unreferenced (0).

func (*PostgresDB) BlobRowExists added in v0.4.0

func (p *PostgresDB) BlobRowExists(ctx context.Context, sha256 string) (bool, error)

func (*PostgresDB) ClaimPendingWebhookDeliveries added in v0.2.0

func (p *PostgresDB) ClaimPendingWebhookDeliveries(ctx context.Context, limit int, lease time.Duration) ([]*models.WebhookDelivery, error)

ClaimPendingWebhookDeliveries atomically claims up to limit due deliveries (pending, next_retry_at unset or elapsed) for lease: it pushes their next_retry_at to the end of the lease under FOR UPDATE SKIP LOCKED, so concurrent pollers on any number of server instances never receive the same row. A claimed delivery that is never completed becomes claimable again once the lease expires.

func (*PostgresDB) Close

func (p *PostgresDB) Close() error

Close closes the database connection.

func (*PostgresDB) ConsumeSAMLAssertion added in v0.2.0

func (p *PostgresDB) ConsumeSAMLAssertion(ctx context.Context, providerSlug, assertionID string, expiresAt time.Time) (bool, error)

ConsumeSAMLAssertion records a SAML assertion ID as used and reports whether this call was the first to consume it. A false result means the assertion was already accepted before (replay). Expired records are purged opportunistically.

func (*PostgresDB) CountBlobsOnStorageBackend added in v0.2.0

func (p *PostgresDB) CountBlobsOnStorageBackend(ctx context.Context, backendID string) (int64, error)

CountBlobsOnStorageBackend returns how many blobs are recorded on a storage backend.

func (*PostgresDB) CountRepositories

func (p *PostgresDB) CountRepositories(ctx context.Context, formatFilter string) (int, error)

func (*PostgresDB) CountUsers

func (p *PostgresDB) CountUsers(ctx context.Context) (int, error)

func (*PostgresDB) CreateBackupJob

func (p *PostgresDB) CreateBackupJob(ctx context.Context, job *models.BackupJob) error

CreateBackupJob creates a new backup job.

func (*PostgresDB) CreateBootstrapAdmin added in v0.2.0

func (p *PostgresDB) CreateBootstrapAdmin(ctx context.Context, username, passwordHash string) (bool, error)

CreateBootstrapAdmin creates the first admin user and binds it to the admin-all permission target in one transaction guarded by an advisory lock. It returns false (and creates nothing) when a user already exists, which is what a replica that lost the first-boot race observes.

func (*PostgresDB) CreateBundlePromotion

func (p *PostgresDB) CreateBundlePromotion(ctx context.Context, pr *models.BundlePromotion) error

func (*PostgresDB) CreateCargoCrate

func (p *PostgresDB) CreateCargoCrate(ctx context.Context, crate *models.CargoCrate) error

CreateCargoCrate creates a new Cargo crate.

cargo_crates has no size_bytes column; the crate blob is upserted with size_bytes=0.

func (*PostgresDB) CreateCleanupPolicy

func (p *PostgresDB) CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error

CreateCleanupPolicy creates a new cleanup policy.

func (*PostgresDB) CreateComponent

func (p *PostgresDB) CreateComponent(ctx context.Context, component *models.Component) error

func (*PostgresDB) CreateConanPackage

func (p *PostgresDB) CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error

CreateConanPackage creates a new Conan package.

conan_packages.blob_id is nullable (it is not declared NOT NULL) and the model has no dedicated hash field, so the blob key doubles as the blobs.sha256 value (self-referential, unique per upload — same pattern as docker blobs).

func (*PostgresDB) CreateCondaPackage

func (p *PostgresDB) CreateCondaPackage(ctx context.Context, pkg *models.CondaPackage) error

CreateCondaPackage creates a new Conda package.

conda_packages has no md5 column and the blobs table only tracks sha256, so pkg.MD5 never round-trips.

func (*PostgresDB) CreateDebPackage

func (p *PostgresDB) CreateDebPackage(ctx context.Context, pkg *models.Component, distID, compID string) error

CreateDebPackage inserts a DEB package with distribution and component references.

func (*PostgresDB) CreateDebianArchitecture

func (p *PostgresDB) CreateDebianArchitecture(ctx context.Context, arch *models.DebianArchitecture) error

func (*PostgresDB) CreateDebianComponent

func (p *PostgresDB) CreateDebianComponent(ctx context.Context, comp *models.DebianComponent) error

func (*PostgresDB) CreateDebianDistribution

func (p *PostgresDB) CreateDebianDistribution(ctx context.Context, dist *models.DebianDistribution) error

func (*PostgresDB) CreateDockerBlob

func (p *PostgresDB) CreateDockerBlob(ctx context.Context, blob *models.DockerBlob) error

CreateDockerBlob upserts the blob's content into the global blobs table (docker_blobs.blob_id FKs into blobs, which holds the media type, size and sha256) and inserts the per-repo docker_blobs registry row referencing it.

func (*PostgresDB) CreateDockerManifest

func (p *PostgresDB) CreateDockerManifest(ctx context.Context, m *models.DockerManifest) error

CreateDockerManifest upserts the manifest row. When m.Refs is set, the references of the manifest body are recorded in the same transaction, under the shared per-repository docker lock that registry GC takes exclusively before it deletes anything: GC then sees either none of this push or all of it, never a manifest whose references it cannot see yet.

func (*PostgresDB) CreateDockerUpload

func (p *PostgresDB) CreateDockerUpload(ctx context.Context, upload *models.DockerUpload) error

func (*PostgresDB) CreateGoModule

func (p *PostgresDB) CreateGoModule(ctx context.Context, mod *models.GoModule) error

CreateGoModule creates a new Go module record.

gomod_modules stores two blobs (zip archive + go.mod file) via zip_blob_id/ mod_blob_id FKs into the global blobs table. The mod blob has no dedicated hash field on models.GoModule, so its own blob key is used as the blobs.sha256 value (self-referential, mirrors the docker blob pattern) — it never collides since blob keys are unique per upload.

func (*PostgresDB) CreateGroup

func (p *PostgresDB) CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)

func (*PostgresDB) CreateHelmChart

func (p *PostgresDB) CreateHelmChart(ctx context.Context, chart *models.HelmChart) error

CreateHelmChart creates a new Helm chart.

func (*PostgresDB) CreateIvyArtifact

func (p *PostgresDB) CreateIvyArtifact(ctx context.Context, artifact *models.IvyArtifact) error

CreateIvyArtifact creates a new Ivy artifact.

func (*PostgresDB) CreateLicensePolicy

func (p *PostgresDB) CreateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error

CreateLicensePolicy creates a new license policy.

func (*PostgresDB) CreateLicenseScanResult

func (p *PostgresDB) CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error

CreateLicenseScanResult creates a new license scan result (UPSERT).

func (*PostgresDB) CreateMavenArtifact

func (p *PostgresDB) CreateMavenArtifact(ctx context.Context, a *models.MavenArtifact) error

func (*PostgresDB) CreateNPMPackage

func (p *PostgresDB) CreateNPMPackage(ctx context.Context, pkg *models.NPMPackage) (*models.NPMPackage, error)

func (*PostgresDB) CreateNPMVersion

func (p *PostgresDB) CreateNPMVersion(ctx context.Context, v *models.NPMVersion) (*models.NPMVersion, error)

func (*PostgresDB) CreateNuGetPackage

func (p *PostgresDB) CreateNuGetPackage(ctx context.Context, pkg *models.NuGetPackage) error

func (*PostgresDB) CreateOrganization

func (p *PostgresDB) CreateOrganization(ctx context.Context, org *models.Organization) error

func (*PostgresDB) CreatePackageDelta

func (p *PostgresDB) CreatePackageDelta(ctx context.Context, d *models.PackageDelta) error

func (*PostgresDB) CreatePermissionAssignment

func (p *PostgresDB) CreatePermissionAssignment(ctx context.Context, assignment *models.PermissionAssignment) error

func (*PostgresDB) CreatePermissionTarget

func (p *PostgresDB) CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)

func (*PostgresDB) CreatePromotionPipeline

func (p *PostgresDB) CreatePromotionPipeline(ctx context.Context, pp *models.PromotionPipeline) error

func (*PostgresDB) CreatePyPIPackage

func (p *PostgresDB) CreatePyPIPackage(ctx context.Context, pkg *models.PyPIPackage) error

func (*PostgresDB) CreateRPMRepo

func (p *PostgresDB) CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error

func (*PostgresDB) CreateReleaseBundle

func (p *PostgresDB) CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error

func (*PostgresDB) CreateRepository

func (p *PostgresDB) CreateRepository(ctx context.Context, repo *models.Repository) error

func (*PostgresDB) CreateRepositoryWithMembers added in v0.2.0

func (p *PostgresDB) CreateRepositoryWithMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error

CreateRepositoryWithMembers inserts a repository and (for group repos) its ordered member list in a single transaction, so a failing member insert cannot leave a half-created group behind.

func (*PostgresDB) CreateRpmPackage

func (p *PostgresDB) CreateRpmPackage(ctx context.Context, pkg *models.Component) error

CreateRpmPackage inserts an RPM package.

func (*PostgresDB) CreateRubyGem

func (p *PostgresDB) CreateRubyGem(ctx context.Context, gem *models.RubyGem) error

CreateRubyGem creates a new RubyGem.

gem.Size is persisted on the row (for quota release) and recorded as the blob's size_bytes.

func (*PostgresDB) CreateSBOMReport

func (p *PostgresDB) CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error

CreateSBOMReport creates or updates an SBOM report (upsert). The caller (internal/api/sbom.go) is expected to have already written the SBOM bytes into the blob store and set report.BlobSHA256/BlobSizeBytes; this upserts the corresponding blobs row and stores the resulting blob_id alongside the report metadata. A zero-value BlobSHA256 stores a NULL blob_id.

func (*PostgresDB) CreateSBTArtifact

func (p *PostgresDB) CreateSBTArtifact(ctx context.Context, artifact *models.SBTArtifact) error

CreateSBTArtifact inserts a new SBT artifact record.

func (*PostgresDB) CreateSSOProvider

func (p *PostgresDB) CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error

func (*PostgresDB) CreateSecretScanResult

func (p *PostgresDB) CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error

CreateSecretScanResult creates a new secret scan result (UPSERT).

func (*PostgresDB) CreateSession

func (p *PostgresDB) CreateSession(ctx context.Context, session *models.Session) (*models.Session, error)

func (*PostgresDB) CreateStorageBackend

func (p *PostgresDB) CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error

CreateStorageBackend creates a new storage backend configuration.

func (*PostgresDB) CreateToken

func (p *PostgresDB) CreateToken(ctx context.Context, token *models.Token) (*models.Token, error)

func (*PostgresDB) CreateUser

func (p *PostgresDB) CreateUser(ctx context.Context, user *models.User) (*models.User, error)

func (*PostgresDB) CreateVulnScanResult

func (p *PostgresDB) CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error

CreateVulnScanResult creates or updates a vulnerability scan result.

func (*PostgresDB) CreateWebhook

func (p *PostgresDB) CreateWebhook(ctx context.Context, wh *models.Webhook) error

CreateWebhook creates a new webhook.

func (*PostgresDB) CreateWebhookDelivery

func (p *PostgresDB) CreateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error

CreateWebhookDelivery creates a new webhook delivery record.

func (*PostgresDB) DecrementStorageUsage

func (p *PostgresDB) DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error

DecrementStorageUsage gives a reservation back (or accounts for a delete). A repository without a quota row has nothing to decrement.

func (*PostgresDB) DeleteAIAnalysis

func (p *PostgresDB) DeleteAIAnalysis(ctx context.Context, repoID, artifactID string) error

DeleteAIAnalysis removes an AI analysis record.

func (*PostgresDB) DeleteArtifactProperty

func (p *PostgresDB) DeleteArtifactProperty(ctx context.Context, repoID, artifactID, key string) error

DeleteArtifactProperty deletes an artifact property.

func (*PostgresDB) DeleteBlobIfUnreferenced added in v0.2.0

func (p *PostgresDB) DeleteBlobIfUnreferenced(ctx context.Context, sha256 string, deleteStorage func(ctx context.Context) error) (bool, error)

DeleteBlobIfUnreferenced atomically removes the blobs row for sha256 and calls deleteStorage, but only when no package row still references it. The check, row delete and storage delete run under the blob advisory lock; if storage deletion fails the row delete is rolled back. Returns true when the blob was removed.

func (*PostgresDB) DeleteCargoCrate

func (p *PostgresDB) DeleteCargoCrate(ctx context.Context, id string) error

func (*PostgresDB) DeleteCleanupPolicy

func (p *PostgresDB) DeleteCleanupPolicy(ctx context.Context, id string) error

DeleteCleanupPolicy deletes a cleanup policy.

func (*PostgresDB) DeleteComponent

func (p *PostgresDB) DeleteComponent(ctx context.Context, componentID string) error

func (*PostgresDB) DeleteConanPackage

func (p *PostgresDB) DeleteConanPackage(ctx context.Context, id string) error

func (*PostgresDB) DeleteCondaPackage

func (p *PostgresDB) DeleteCondaPackage(ctx context.Context, id string) error

func (*PostgresDB) DeleteDockerBlob

func (p *PostgresDB) DeleteDockerBlob(ctx context.Context, repoID, digest string) error

func (*PostgresDB) DeleteDockerBlobsForGC added in v0.4.0

func (p *PostgresDB) DeleteDockerBlobsForGC(ctx context.Context, repoID string, digests []string, grace time.Duration) ([]*models.DockerGCBlob, error)

func (*PostgresDB) DeleteDockerManifest

func (p *PostgresDB) DeleteDockerManifest(ctx context.Context, repoID, image, digest string) error

func (*PostgresDB) DeleteDockerManifestsForGC added in v0.4.0

func (p *PostgresDB) DeleteDockerManifestsForGC(ctx context.Context, repoID string, ids []string, grace time.Duration) ([]*models.DockerGCManifest, error)

func (*PostgresDB) DeleteDockerTag

func (p *PostgresDB) DeleteDockerTag(ctx context.Context, repoID, image, name string) error

func (*PostgresDB) DeleteDockerTagsByDigest added in v0.4.0

func (p *PostgresDB) DeleteDockerTagsByDigest(ctx context.Context, repoID, image, digest string) error

func (*PostgresDB) DeleteDockerUpload

func (p *PostgresDB) DeleteDockerUpload(ctx context.Context, repositoryID, uploadUUID string) error

func (*PostgresDB) DeleteExpiredProxyCacheEntries

func (p *PostgresDB) DeleteExpiredProxyCacheEntries(ctx context.Context) (int64, error)

func (*PostgresDB) DeleteGoModule

func (p *PostgresDB) DeleteGoModule(ctx context.Context, repoID, modulePath, version string) error

DeleteGoModule deletes a Go module.

func (*PostgresDB) DeleteGroup

func (p *PostgresDB) DeleteGroup(ctx context.Context, id string) error

func (*PostgresDB) DeleteHelmChart

func (p *PostgresDB) DeleteHelmChart(ctx context.Context, repoID, name, version string) error

func (*PostgresDB) DeleteIvyArtifact

func (p *PostgresDB) DeleteIvyArtifact(ctx context.Context, id string) error

func (*PostgresDB) DeleteLicensePolicy

func (p *PostgresDB) DeleteLicensePolicy(ctx context.Context, id string) error

DeleteLicensePolicy deletes a license policy by ID.

func (*PostgresDB) DeleteMavenArtifact

func (p *PostgresDB) DeleteMavenArtifact(ctx context.Context, id string) error

func (*PostgresDB) DeleteNPMDistTag

func (p *PostgresDB) DeleteNPMDistTag(ctx context.Context, packageID, tag string) error

func (*PostgresDB) DeleteNPMPackage

func (p *PostgresDB) DeleteNPMPackage(ctx context.Context, packageID string) error

func (*PostgresDB) DeleteNPMVersion

func (p *PostgresDB) DeleteNPMVersion(ctx context.Context, packageID, version string) error

func (*PostgresDB) DeleteNuGetPackage

func (p *PostgresDB) DeleteNuGetPackage(ctx context.Context, repoID, packageID, version string) error

func (*PostgresDB) DeleteOrganization

func (p *PostgresDB) DeleteOrganization(ctx context.Context, id string) error

func (*PostgresDB) DeleteOtherSessionsByUser added in v0.2.0

func (p *PostgresDB) DeleteOtherSessionsByUser(ctx context.Context, userID, keepTokenHash string) error

DeleteOtherSessionsByUser revokes every session of a user except the one identified by keepTokenHash.

func (*PostgresDB) DeletePackageDelta

func (p *PostgresDB) DeletePackageDelta(ctx context.Context, id string) error

func (*PostgresDB) DeletePermissionAssignment

func (p *PostgresDB) DeletePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error

func (*PostgresDB) DeletePermissionTarget

func (p *PostgresDB) DeletePermissionTarget(ctx context.Context, id string) error

func (*PostgresDB) DeletePromotionPipeline

func (p *PostgresDB) DeletePromotionPipeline(ctx context.Context, id string) error

func (*PostgresDB) DeleteProxyCacheEntry

func (p *PostgresDB) DeleteProxyCacheEntry(ctx context.Context, repoID, cacheKey string) error

func (*PostgresDB) DeletePyPIPackage

func (p *PostgresDB) DeletePyPIPackage(ctx context.Context, repoID, name, version, filename string) error

func (*PostgresDB) DeleteRawArtifact

func (p *PostgresDB) DeleteRawArtifact(ctx context.Context, repoID, path string) error

DeleteRawArtifact deletes a raw artifact by repo ID and path.

func (*PostgresDB) DeleteReleaseBundle

func (p *PostgresDB) DeleteReleaseBundle(ctx context.Context, id string) error

func (*PostgresDB) DeleteRepository

func (p *PostgresDB) DeleteRepository(ctx context.Context, id string) error

func (*PostgresDB) DeleteRubyGem

func (p *PostgresDB) DeleteRubyGem(ctx context.Context, id string) error

func (*PostgresDB) DeleteSBOMReport

func (p *PostgresDB) DeleteSBOMReport(ctx context.Context, id string) error

DeleteSBOMReport deletes an SBOM report by ID.

func (*PostgresDB) DeleteSBOMReportInRepo added in v0.2.0

func (p *PostgresDB) DeleteSBOMReportInRepo(ctx context.Context, repoID, id string) (string, error)

DeleteSBOMReportInRepo deletes the SBOM report with the given ID scoped to repoID and returns the sha256 of the blob it referenced ("" when it had none). Callers should afterwards remove the blob from storage if it is unreferenced (storage.SafeDeleteBlob). Returns ErrSBOMReportNotFound when nothing matched.

func (*PostgresDB) DeleteSBTArtifact

func (p *PostgresDB) DeleteSBTArtifact(ctx context.Context, id string) error

func (*PostgresDB) DeleteSSOProvider

func (p *PostgresDB) DeleteSSOProvider(ctx context.Context, id string) error

func (*PostgresDB) DeleteSession

func (p *PostgresDB) DeleteSession(ctx context.Context, tokenHash string) error

func (*PostgresDB) DeleteSessionsByUser added in v0.2.0

func (p *PostgresDB) DeleteSessionsByUser(ctx context.Context, userID string) error

DeleteSessionsByUser revokes every session of a user.

func (*PostgresDB) DeleteStorageBackend

func (p *PostgresDB) DeleteStorageBackend(ctx context.Context, id string) error

DeleteStorageBackend deletes a storage backend.

func (*PostgresDB) DeleteVulnScanResult added in v0.2.0

func (p *PostgresDB) DeleteVulnScanResult(ctx context.Context, repoID, id string) error

DeleteVulnScanResult deletes a vuln scan result (and its owning scan job) by ID, scoped to repoID. Returns ErrVulnScanNotFound when nothing matched.

func (*PostgresDB) DeleteWebhook

func (p *PostgresDB) DeleteWebhook(ctx context.Context, id string) error

DeleteWebhook deletes a webhook.

func (*PostgresDB) EnsureBlob

func (p *PostgresDB) EnsureBlob(ctx context.Context, sha256, mediaType string, size int64) (string, error)

EnsureBlob ensures the global blobs table has a row for sha256 (creating it, or updating its media type, if it already exists) and returns its blobs.id. Manifests are stored directly in the blob store without a per-repo registry row (unlike docker_blobs), so this is the manifest handlers' entry point into upsertBlobWithMediaType.

func (*PostgresDB) GetAIAnalysis

func (p *PostgresDB) GetAIAnalysis(ctx context.Context, repoID, artifactID string) (*models.AIAnalysis, error)

GetAIAnalysis retrieves an AI analysis by repo and artifact ID.

func (*PostgresDB) GetArtifactProperty

func (p *PostgresDB) GetArtifactProperty(ctx context.Context, repoID, artifactID, key string) (string, error)

GetArtifactProperty gets a single artifact property.

func (*PostgresDB) GetBackupJob

func (p *PostgresDB) GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)

GetBackupJob retrieves a backup job by ID.

func (*PostgresDB) GetBundleItem

func (p *PostgresDB) GetBundleItem(ctx context.Context, bundleID, sha256 string) (*models.ReleaseBundleItem, error)

func (*PostgresDB) GetCargoCrate

func (p *PostgresDB) GetCargoCrate(ctx context.Context, repoID, name, version string) (*models.CargoCrate, error)

func (*PostgresDB) GetCleanupPolicy

func (p *PostgresDB) GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)

GetCleanupPolicy retrieves a cleanup policy by ID.

func (*PostgresDB) GetComponentByFilename

func (p *PostgresDB) GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)

func (*PostgresDB) GetComponentByID

func (p *PostgresDB) GetComponentByID(ctx context.Context, id string) (*models.Component, error)

GetComponentByID looks up a package by its primary key, trying rpm_packages then deb_packages (row IDs are shared across the rpm_packages and deb_packages tables).

func (*PostgresDB) GetComponentsByRepo

func (p *PostgresDB) GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)

GetComponentsByRepo lists RPM packages for a repository.

func (*PostgresDB) GetConanPackage

func (p *PostgresDB) GetConanPackage(ctx context.Context, repoID, name, version, userChannel, recipeRevision string) (*models.ConanPackage, error)

func (*PostgresDB) GetCondaPackage

func (p *PostgresDB) GetCondaPackage(ctx context.Context, repoID, name, version, buildString, platform string) (*models.CondaPackage, error)

func (*PostgresDB) GetDB

func (p *PostgresDB) GetDB() *sql.DB

GetDB returns the underlying sql.DB connection.

func (*PostgresDB) GetDebBlobInfo added in v0.2.0

func (p *PostgresDB) GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)

GetDebBlobInfo resolves a blobs.id UUID to its content sha256 and size ("" / 0 if unknown).

func (*PostgresDB) GetDebPackageByID

func (p *PostgresDB) GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)

GetDebPackageByID fetches a DEB package by its primary key.

func (*PostgresDB) GetDebianArchitecturesByDist

func (p *PostgresDB) GetDebianArchitecturesByDist(ctx context.Context, distID string) ([]models.DebianArchitecture, error)

func (*PostgresDB) GetDebianComponentsByDist

func (p *PostgresDB) GetDebianComponentsByDist(ctx context.Context, distID string) ([]models.DebianComponent, error)

func (*PostgresDB) GetDebianDistribution

func (p *PostgresDB) GetDebianDistribution(ctx context.Context, repoID string, name string) (*models.DebianDistribution, error)

func (*PostgresDB) GetDebianDistributionsByRepo

func (p *PostgresDB) GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)

func (*PostgresDB) GetDebianPackageByFilename

func (p *PostgresDB) GetDebianPackageByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)

func (*PostgresDB) GetDebianPackagesByDistComp

func (p *PostgresDB) GetDebianPackagesByDistComp(ctx context.Context, repoID string, dist string, comp string, arch string) ([]models.Component, error)

func (*PostgresDB) GetDockerBlob

func (p *PostgresDB) GetDockerBlob(ctx context.Context, repoID, digest string) (*models.DockerBlob, error)

func (*PostgresDB) GetDockerManifest

func (p *PostgresDB) GetDockerManifest(ctx context.Context, repoID, image, digest string) (*models.DockerManifest, error)

func (*PostgresDB) GetDockerTag

func (p *PostgresDB) GetDockerTag(ctx context.Context, repoID, image, name string) (*models.DockerTag, error)

func (*PostgresDB) GetDockerUpload

func (p *PostgresDB) GetDockerUpload(ctx context.Context, repositoryID, uploadUUID string) (*models.DockerUpload, error)

func (*PostgresDB) GetGoModule

func (p *PostgresDB) GetGoModule(ctx context.Context, repoID, modulePath, version string) (*models.GoModule, error)

GetGoModule retrieves a Go module by repo, path, and version.

func (*PostgresDB) GetGroupByID

func (p *PostgresDB) GetGroupByID(ctx context.Context, id string) (*models.Group, error)

func (*PostgresDB) GetGroupByName

func (p *PostgresDB) GetGroupByName(ctx context.Context, name string) (*models.Group, error)

func (*PostgresDB) GetHelmChart

func (p *PostgresDB) GetHelmChart(ctx context.Context, repoID, name, version string) (*models.HelmChart, error)

func (*PostgresDB) GetIvyArtifact

func (p *PostgresDB) GetIvyArtifact(ctx context.Context, repoID, organisation, module, revision, artifactName, artifactExt string) (*models.IvyArtifact, error)

func (*PostgresDB) GetLatestGoModule

func (p *PostgresDB) GetLatestGoModule(ctx context.Context, repoID, modulePath string) (*models.GoModule, error)

GetLatestGoModule gets the latest version of a module.

func (*PostgresDB) GetLatestSnapshot

func (p *PostgresDB) GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)

func (*PostgresDB) GetLicensePolicy

func (p *PostgresDB) GetLicensePolicy(ctx context.Context, id string) (*models.LicensePolicy, error)

GetLicensePolicy gets a license policy by ID.

func (*PostgresDB) GetLicenseScanResult

func (p *PostgresDB) GetLicenseScanResult(ctx context.Context, repoID, artifactID string) (*models.LicenseScanResult, error)

GetLicenseScanResult gets a license scan result by repo and artifact ID.

func (*PostgresDB) GetLicenseScanResultByID added in v0.2.0

func (p *PostgresDB) GetLicenseScanResultByID(ctx context.Context, repoID, id string) (*models.LicenseScanResult, error)

GetLicenseScanResultByID returns the license scan result with the given ID scoped to repoID, or nil.

func (*PostgresDB) GetMavenArtifactByPath

func (p *PostgresDB) GetMavenArtifactByPath(ctx context.Context, repoID, path string) (*models.MavenArtifact, error)

func (*PostgresDB) GetMavenArtifactsByGA

func (p *PostgresDB) GetMavenArtifactsByGA(ctx context.Context, repoID, groupID, artifactID string) ([]*models.MavenArtifact, error)

func (*PostgresDB) GetMavenArtifactsByGAV

func (p *PostgresDB) GetMavenArtifactsByGAV(ctx context.Context, repoID, groupID, artifactID, version string) ([]*models.MavenArtifact, error)

func (*PostgresDB) GetNPMDistTags

func (p *PostgresDB) GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)

func (*PostgresDB) GetNPMPackageByName

func (p *PostgresDB) GetNPMPackageByName(ctx context.Context, repoID, fullName string) (*models.NPMPackage, error)

func (*PostgresDB) GetNPMVersion

func (p *PostgresDB) GetNPMVersion(ctx context.Context, packageID, version string) (*models.NPMVersion, error)

func (*PostgresDB) GetNPMVersionsByPackage

func (p *PostgresDB) GetNPMVersionsByPackage(ctx context.Context, packageID string) ([]*models.NPMVersion, error)

func (*PostgresDB) GetNuGetPackage

func (p *PostgresDB) GetNuGetPackage(ctx context.Context, repoID, packageID, version string) (*models.NuGetPackage, error)

func (*PostgresDB) GetOrCreateDebianArchitecture added in v0.2.0

func (p *PostgresDB) GetOrCreateDebianArchitecture(ctx context.Context, distID, name string) (*models.DebianArchitecture, error)

GetOrCreateDebianArchitecture returns the architecture, creating it atomically if missing.

func (*PostgresDB) GetOrCreateDebianComponent added in v0.2.0

func (p *PostgresDB) GetOrCreateDebianComponent(ctx context.Context, distID, name string) (*models.DebianComponent, error)

GetOrCreateDebianComponent returns the component, creating it atomically if missing.

func (*PostgresDB) GetOrCreateDebianDistribution added in v0.2.0

func (p *PostgresDB) GetOrCreateDebianDistribution(ctx context.Context, repoID, name string) (*models.DebianDistribution, error)

GetOrCreateDebianDistribution returns the distribution, creating it atomically if missing.

func (*PostgresDB) GetOrCreateGroup

func (p *PostgresDB) GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)

func (*PostgresDB) GetOrCreatePermissionAssignment

func (p *PostgresDB) GetOrCreatePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error

func (*PostgresDB) GetOrCreateStorageQuota

func (p *PostgresDB) GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)

GetOrCreateStorageQuota gets or creates a storage quota for a repository.

func (*PostgresDB) GetOrgMember

func (p *PostgresDB) GetOrgMember(ctx context.Context, orgID, userID string) (*models.OrgMember, error)

func (*PostgresDB) GetOrganization

func (p *PostgresDB) GetOrganization(ctx context.Context, id string) (*models.Organization, error)

func (*PostgresDB) GetOrganizationByName

func (p *PostgresDB) GetOrganizationByName(ctx context.Context, name string) (*models.Organization, error)

func (*PostgresDB) GetPackageDelta

func (p *PostgresDB) GetPackageDelta(ctx context.Context, repoID, fromSHA256, toSHA256 string) (*models.PackageDelta, error)

func (*PostgresDB) GetPermissionTargetByID

func (p *PostgresDB) GetPermissionTargetByID(ctx context.Context, id string) (*models.PermissionTarget, error)

func (*PostgresDB) GetPermissionTargetByName

func (p *PostgresDB) GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)

func (*PostgresDB) GetPermissionTargetsForPrincipal

func (p *PostgresDB) GetPermissionTargetsForPrincipal(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)

GetPermissionTargetsForPrincipal returns the permission targets held by a user and its groups, from the auth cache when fresh.

func (*PostgresDB) GetPermissionTargetsForPrincipalUncached added in v0.4.0

func (p *PostgresDB) GetPermissionTargetsForPrincipalUncached(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)

func (*PostgresDB) GetPromotionPipelineByID

func (p *PostgresDB) GetPromotionPipelineByID(ctx context.Context, id string) (*models.PromotionPipeline, error)

func (*PostgresDB) GetPromotionPipelineByName

func (p *PostgresDB) GetPromotionPipelineByName(ctx context.Context, name string) (*models.PromotionPipeline, error)

func (*PostgresDB) GetProxyCacheEntry

func (p *PostgresDB) GetProxyCacheEntry(ctx context.Context, repoID, cacheKey string) (*models.ProxyCacheEntry, error)

func (*PostgresDB) GetPyPIPackage

func (p *PostgresDB) GetPyPIPackage(ctx context.Context, repoID, name, version, filename string) (*models.PyPIPackage, error)

func (*PostgresDB) GetRPMRepo

func (p *PostgresDB) GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)

func (*PostgresDB) GetRawArtifact

func (p *PostgresDB) GetRawArtifact(ctx context.Context, repoID, path string) (*models.RawArtifact, error)

GetRawArtifact retrieves a raw artifact by repo ID and path.

func (*PostgresDB) GetReleaseBundle

func (p *PostgresDB) GetReleaseBundle(ctx context.Context, name, version string) (*models.ReleaseBundle, error)

func (*PostgresDB) GetReleaseBundleByID

func (p *PostgresDB) GetReleaseBundleByID(ctx context.Context, id string) (*models.ReleaseBundle, error)

func (*PostgresDB) GetRepoComponentBlob added in v0.3.0

func (p *PostgresDB) GetRepoComponentBlob(ctx context.Context, repoID, id string) (*models.ComponentBlob, error)

GetRepoComponentBlob resolves a row id of the package listing (ListComponentsByRepo) to its blob, scoped to repoID. It returns nil, nil when no row of any format has that id in the repository, or when id is not a UUID.

func (*PostgresDB) GetRepoMetadataByPath

func (p *PostgresDB) GetRepoMetadataByPath(ctx context.Context, repositoryID string, path string) (*models.RepoMetadata, error)

func (*PostgresDB) GetRepoMetadataByRepo

func (p *PostgresDB) GetRepoMetadataByRepo(ctx context.Context, repositoryID string) ([]models.RepoMetadata, error)

func (*PostgresDB) GetRepositoryByID

func (p *PostgresDB) GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)

GetRepositoryByID retrieves a repository by its primary key.

func (*PostgresDB) GetRepositoryByName

func (p *PostgresDB) GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)

GetRepositoryByName returns the repository with the given name, from the auth cache when fresh.

func (*PostgresDB) GetRepositoryByNameUncached added in v0.4.0

func (p *PostgresDB) GetRepositoryByNameUncached(ctx context.Context, name string) (*models.Repository, error)

func (*PostgresDB) GetRpmPackageByID

func (p *PostgresDB) GetRpmPackageByID(ctx context.Context, id string) (*models.RpmPackage, error)

GetRpmPackageByID fetches an RPM package by its primary key.

func (*PostgresDB) GetRubyGem

func (p *PostgresDB) GetRubyGem(ctx context.Context, repoID, name, version, platform string) (*models.RubyGem, error)

func (*PostgresDB) GetSBOMReport

func (p *PostgresDB) GetSBOMReport(ctx context.Context, repoID, artifactID, format, specVersion string) (*models.SBOMReport, error)

GetSBOMReport retrieves an SBOM report by repo, artifact, format, and spec version. BlobSHA256 is resolved via a LEFT JOIN with blobs and is empty for reports that predate blob_id or were created with no content.

func (*PostgresDB) GetSBOMReportByID added in v0.2.0

func (p *PostgresDB) GetSBOMReportByID(ctx context.Context, repoID, id string) (*models.SBOMReport, error)

GetSBOMReportByID returns the SBOM report with the given ID scoped to repoID, or nil.

func (*PostgresDB) GetSBTArtifact

func (p *PostgresDB) GetSBTArtifact(ctx context.Context, repoID, groupID, artifactID, version, filename string) (*models.SBTArtifact, error)

func (*PostgresDB) GetSSOProviderByID

func (p *PostgresDB) GetSSOProviderByID(ctx context.Context, id string) (*models.SSOProvider, error)

func (*PostgresDB) GetSSOProviderBySlug

func (p *PostgresDB) GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)

func (*PostgresDB) GetSecretScanResult

func (p *PostgresDB) GetSecretScanResult(ctx context.Context, repoID, artifactID string) (*models.SecretScanResult, error)

GetSecretScanResult gets a secret scan result by repo and artifact ID.

func (*PostgresDB) GetSessionByTokenHash

func (p *PostgresDB) GetSessionByTokenHash(ctx context.Context, hash string) (*models.Session, error)

func (*PostgresDB) GetStorageBackend

func (p *PostgresDB) GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)

GetStorageBackend gets a storage backend by name.

func (*PostgresDB) GetSystemSetting

func (p *PostgresDB) GetSystemSetting(ctx context.Context, key string) (string, error)

GetSystemSetting retrieves a system setting by key.

func (*PostgresDB) GetTokenByHash

func (p *PostgresDB) GetTokenByHash(ctx context.Context, hash string) (*models.Token, error)

GetTokenByHash returns the token with the given hash, from the auth cache when fresh.

func (*PostgresDB) GetTokenByHashUncached added in v0.4.0

func (p *PostgresDB) GetTokenByHashUncached(ctx context.Context, hash string) (*models.Token, error)

func (*PostgresDB) GetTokenByID

func (p *PostgresDB) GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)

func (*PostgresDB) GetUserByEmail

func (p *PostgresDB) GetUserByEmail(ctx context.Context, email string) (*models.User, error)

func (*PostgresDB) GetUserByExternalID

func (p *PostgresDB) GetUserByExternalID(ctx context.Context, externalID, providerSlug string) (*models.User, error)

func (*PostgresDB) GetUserByID

func (p *PostgresDB) GetUserByID(ctx context.Context, id string) (*models.User, error)

GetUserByID returns the user with the given ID, from the auth cache when fresh.

func (*PostgresDB) GetUserByIDUncached added in v0.4.0

func (p *PostgresDB) GetUserByIDUncached(ctx context.Context, id string) (*models.User, error)

func (*PostgresDB) GetUserByUsername

func (p *PostgresDB) GetUserByUsername(ctx context.Context, username string) (*models.User, error)

func (*PostgresDB) GetVulnScanResult

func (p *PostgresDB) GetVulnScanResult(ctx context.Context, repoID, artifactID string) (*models.VulnScanResult, error)

GetVulnScanResult gets a vulnerability scan result by repo and artifact ID. scan_jobs' UNIQUE(artifact_ref_id, scan_type, scanner) allows more than one scanner (osv/trivy/grype/...) to have scanned the same artifact, so this orders by most-recently-created and takes the first row instead of letting QueryRowContext pick an arbitrary one nondeterministically.

func (*PostgresDB) GetVulnScanResultByID added in v0.2.0

func (p *PostgresDB) GetVulnScanResultByID(ctx context.Context, repoID, id string) (*models.VulnScanResult, error)

GetVulnScanResultByID returns the vuln scan result with the given ID scoped to repoID, or nil.

func (*PostgresDB) GetWebhook

func (p *PostgresDB) GetWebhook(ctx context.Context, id string) (*models.Webhook, error)

GetWebhook retrieves a webhook by ID.

func (*PostgresDB) IncrementCargoDownloadCount

func (p *PostgresDB) IncrementCargoDownloadCount(ctx context.Context, repoID, name, version string) error

func (*PostgresDB) IncrementNuGetDownloadCount

func (p *PostgresDB) IncrementNuGetDownloadCount(ctx context.Context, repoID, packageID, version string) error

func (*PostgresDB) IncrementStorageUsage

func (p *PostgresDB) IncrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error

IncrementStorageUsage increments the storage usage for a repository.

func (*PostgresDB) InsertAuditLog

func (p *PostgresDB) InsertAuditLog(ctx context.Context, event *models.AuditLog) error

func (*PostgresDB) IsArtifactQuarantined added in v0.2.0

func (p *PostgresDB) IsArtifactQuarantined(ctx context.Context, repoID string, keys []string) (bool, error)

IsArtifactQuarantined reports whether any of keys (artifact_refs.artifact_path values) identifies an artifact of the repository whose vulnerability, secret or license scan result is flagged quarantined.

func (*PostgresDB) ListAIAnalyses

func (p *PostgresDB) ListAIAnalyses(ctx context.Context, repoID string, status string, limit, offset int) ([]*models.AIAnalysis, int, error)

ListAIAnalyses lists AI analyses for a repository with optional status filter.

func (*PostgresDB) ListAllCondaPackages

func (p *PostgresDB) ListAllCondaPackages(ctx context.Context, repoID string) ([]*models.CondaPackage, error)

ListAllCondaPackages lists all conda packages for a repository across every platform. Used only by backup export, where ListCondaPackages' mandatory platform filter would silently drop everything else.

func (*PostgresDB) ListAllNPMPackages

func (p *PostgresDB) ListAllNPMPackages(ctx context.Context, repoID string) ([]*models.NPMPackage, error)

ListAllNPMPackages lists every npm package for a repository. Used only by backup export.

func (*PostgresDB) ListAllSSOProviders

func (p *PostgresDB) ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)

func (*PostgresDB) ListAllTokens

func (p *PostgresDB) ListAllTokens(ctx context.Context, page, perPage int) ([]*models.Token, int, error)

func (*PostgresDB) ListArtifactProperties

func (p *PostgresDB) ListArtifactProperties(ctx context.Context, repoID, artifactID string) (map[string]string, error)

ListArtifactProperties lists all properties for an artifact.

func (*PostgresDB) ListAuditLogs

func (p *PostgresDB) ListAuditLogs(ctx context.Context, params models.AuditListParams) (*models.AuditPage, error)

ListAuditLogs returns one page of audit entries, newest first. It reads Limit+1 rows to learn whether more follow, so no COUNT(*) runs for keyset (After) paging, and offset paging only counts when the page itself cannot answer (see auditTotal).

func (*PostgresDB) ListBackupJobs

func (p *PostgresDB) ListBackupJobs(ctx context.Context, limit int) ([]*models.BackupJob, error)

ListBackupJobs lists backup jobs with a limit.

func (*PostgresDB) ListBundleItems

func (p *PostgresDB) ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)

func (*PostgresDB) ListBundlePromotions

func (p *PostgresDB) ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)

func (*PostgresDB) ListCargoCrateVersions

func (p *PostgresDB) ListCargoCrateVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)

func (*PostgresDB) ListCleanupPolicies

func (p *PostgresDB) ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)

ListCleanupPolicies lists all cleanup policies for a repository.

func (*PostgresDB) ListComponentsByRepo

func (p *PostgresDB) ListComponentsByRepo(ctx context.Context, repoID, formatFilter string, page, limit int) ([]*models.Component, int, error)

ListComponentsByRepo lists the packages of one repository across every format (see ListRepoComponents in queries/components.sql for the per-format mapping). formatFilter, when non-empty, restricts the result to one format.

func (*PostgresDB) ListConanPackages

func (p *PostgresDB) ListConanPackages(ctx context.Context, repoID string) ([]*models.ConanPackage, error)

func (*PostgresDB) ListCondaPackages

func (p *PostgresDB) ListCondaPackages(ctx context.Context, repoID, platform string) ([]*models.CondaPackage, error)

func (*PostgresDB) ListDebPackageEntries added in v0.2.0

func (p *PostgresDB) ListDebPackageEntries(ctx context.Context, repoID, dist, comp, arch string) ([]models.DebPackageEntry, error)

ListDebPackageEntries returns package entries for a repository in a single query. Empty dist/comp/arch act as wildcards.

func (*PostgresDB) ListDebPackagesByRepo

func (p *PostgresDB) ListDebPackagesByRepo(ctx context.Context, repoID string) ([]*models.DebPackage, error)

ListDebPackagesByRepo lists all DEB packages in a repository.

func (*PostgresDB) ListDockerBlobs

func (p *PostgresDB) ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)

func (*PostgresDB) ListDockerGCBlobs added in v0.4.0

func (p *PostgresDB) ListDockerGCBlobs(ctx context.Context, repoID string, grace time.Duration, excludeManifestIDs []string, limit int) ([]*models.DockerGCBlob, error)

func (*PostgresDB) ListDockerGCManifests added in v0.4.0

func (p *PostgresDB) ListDockerGCManifests(ctx context.Context, repoID string, grace time.Duration) ([]*models.DockerGCManifest, error)

func (*PostgresDB) ListDockerManifestsByRepo

func (p *PostgresDB) ListDockerManifestsByRepo(ctx context.Context, repoID string) ([]*models.DockerManifest, error)

ListDockerManifestsByRepo lists every manifest for a repository, with its blob's sha256 resolved via a JOIN (unlike BlobID above, which is the raw, restore-incompatible blobs.id UUID). Used only by backup export.

func (*PostgresDB) ListDockerManifestsBySubject

func (p *PostgresDB) ListDockerManifestsBySubject(ctx context.Context, repoID, image, subjectDigest string) ([]*models.DockerManifest, error)

ListDockerManifestsBySubject returns manifests in repoID whose OCI `subject` field points at subjectDigest, for the Referrers API (GET /v2/<name>/referrers/<digest>). No sqlc query exists for this lookup, so it runs directly against p.db.

func (*PostgresDB) ListDockerTags

func (p *PostgresDB) ListDockerTags(ctx context.Context, repoID, image, last string, n int) ([]*models.DockerTag, error)

func (*PostgresDB) ListDockerTagsByRepo added in v0.4.0

func (p *PostgresDB) ListDockerTagsByRepo(ctx context.Context, repoID string, limit int) ([]*models.DockerTag, error)

ListDockerTagsByRepo lists tags across every image of a repository, for backup export.

func (*PostgresDB) ListEnabledCleanupPolicies

func (p *PostgresDB) ListEnabledCleanupPolicies(ctx context.Context) ([]*models.CleanupPolicy, error)

ListEnabledCleanupPolicies lists all enabled cleanup policies.

func (*PostgresDB) ListEnabledSSOProviders

func (p *PostgresDB) ListEnabledSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)

func (*PostgresDB) ListGlobalLicensePolicies added in v0.2.0

func (p *PostgresDB) ListGlobalLicensePolicies(ctx context.Context) ([]*models.LicensePolicy, error)

ListGlobalLicensePolicies lists only the global (repository_id IS NULL) license policies.

func (*PostgresDB) ListGoModuleVersions

func (p *PostgresDB) ListGoModuleVersions(ctx context.Context, repoID, modulePath string) ([]*models.GoModule, error)

ListGoModuleVersions lists all versions of a module.

func (*PostgresDB) ListGoModulesByRepo

func (p *PostgresDB) ListGoModulesByRepo(ctx context.Context, repoID string) ([]*models.GoModule, error)

ListGoModulesByRepo lists every module version for a repository. Used only by backup export, where ListGoModuleVersions' mandatory module path filter would silently drop every other module.

func (*PostgresDB) ListGroupMembers

func (p *PostgresDB) ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)

func (*PostgresDB) ListGroups

func (p *PostgresDB) ListGroups(ctx context.Context) ([]*models.Group, error)

func (*PostgresDB) ListGroupsByUser

func (p *PostgresDB) ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)

ListGroupsByUser returns the groups of a user, from the auth cache when fresh.

func (*PostgresDB) ListGroupsByUserUncached added in v0.4.0

func (p *PostgresDB) ListGroupsByUserUncached(ctx context.Context, userID string) ([]*models.Group, error)

func (*PostgresDB) ListHelmChartVersions

func (p *PostgresDB) ListHelmChartVersions(ctx context.Context, repoID, name string) ([]*models.HelmChart, error)

func (*PostgresDB) ListHelmCharts

func (p *PostgresDB) ListHelmCharts(ctx context.Context, repoID string) ([]*models.HelmChart, error)

func (*PostgresDB) ListIvyArtifacts

func (p *PostgresDB) ListIvyArtifacts(ctx context.Context, repoID string) ([]*models.IvyArtifact, error)

func (*PostgresDB) ListLicensePolicies

func (p *PostgresDB) ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)

ListLicensePolicies lists all license policies for a repository (including global policies).

func (*PostgresDB) ListLicenseScanResults

func (p *PostgresDB) ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)

ListLicenseScanResults lists all license scan results for a repository.

func (*PostgresDB) ListMavenArtifactsByRepo

func (p *PostgresDB) ListMavenArtifactsByRepo(ctx context.Context, repoID string) ([]*models.MavenArtifact, error)

ListMavenArtifactsByRepo lists every maven artifact for a repository, with its blob's sha256/size resolved via a JOIN (unlike BlobID on the other Get* methods here, which is the raw, restore-incompatible blobs.id UUID). Used only by backup export.

func (*PostgresDB) ListNPMVersionsByRepo

func (p *PostgresDB) ListNPMVersionsByRepo(ctx context.Context, repoID string) ([]*models.NPMVersion, error)

ListNPMVersionsByRepo lists every npm version for a repository, with its tarball blob's sha256/size resolved via a JOIN (unlike BlobID on the other Get* methods here, which is the raw, restore-incompatible blobs.id UUID). Used only by backup export.

func (*PostgresDB) ListNuGetPackageVersions

func (p *PostgresDB) ListNuGetPackageVersions(ctx context.Context, repoID, packageID string) ([]*models.NuGetPackage, error)

func (*PostgresDB) ListNuGetPackages

func (p *PostgresDB) ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)

func (*PostgresDB) ListOrgGrantsByUser added in v0.4.0

func (p *PostgresDB) ListOrgGrantsByUser(ctx context.Context, userID string) ([]*models.OrgGrant, error)

ListOrgGrantsByUser returns the organization memberships of a user (see models.OrgGrant), from the auth cache when fresh.

func (*PostgresDB) ListOrgMembers

func (p *PostgresDB) ListOrgMembers(ctx context.Context, orgID string) ([]*models.OrgMember, error)

func (*PostgresDB) ListOrganizations

func (p *PostgresDB) ListOrganizations(ctx context.Context, userID string) ([]*models.Organization, error)

func (*PostgresDB) ListPackageDeltas

func (p *PostgresDB) ListPackageDeltas(ctx context.Context, repoID, toSHA256 string) ([]*models.PackageDelta, error)

func (*PostgresDB) ListPendingAIAnalyses

func (p *PostgresDB) ListPendingAIAnalyses(ctx context.Context, limit int) ([]*models.AIAnalysis, error)

ListPendingAIAnalyses returns analyses in "pending" status up to limit.

func (*PostgresDB) ListPermissionTargets

func (p *PostgresDB) ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)

func (*PostgresDB) ListPromotionPipelines

func (p *PostgresDB) ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)

func (*PostgresDB) ListPublicRepositoryNames added in v0.3.0

func (p *PostgresDB) ListPublicRepositoryNames(ctx context.Context) ([]string, error)

ListPublicRepositoryNames returns the names of all repositories flagged public.

func (*PostgresDB) ListPyPIPackageVersions

func (p *PostgresDB) ListPyPIPackageVersions(ctx context.Context, repoID, name string) ([]*models.PyPIPackage, error)

func (*PostgresDB) ListPyPIPackages

func (p *PostgresDB) ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)

func (*PostgresDB) ListRawArtifacts

func (p *PostgresDB) ListRawArtifacts(ctx context.Context, repoID, prefix string) ([]*models.RawArtifact, error)

ListRawArtifacts lists raw artifacts in a repository, optionally filtered by prefix.

func (*PostgresDB) ListReleaseBundles

func (p *PostgresDB) ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)

func (*PostgresDB) ListRepositories

func (p *PostgresDB) ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)

func (*PostgresDB) ListRpmPackagesByRepo

func (p *PostgresDB) ListRpmPackagesByRepo(ctx context.Context, repoID string) ([]*models.RpmPackage, error)

ListRpmPackagesByRepo lists all RPM packages in a repository.

func (*PostgresDB) ListRpmPackagesForMetadata added in v0.2.0

func (p *PostgresDB) ListRpmPackagesForMetadata(ctx context.Context, repoID string) ([]pkgrpm.Package, error)

ListRpmPackagesForMetadata loads every rpm package of a repo with dependency, file and changelog data plus the header range, for metadata generation.

func (*PostgresDB) ListRubyGemVersions

func (p *PostgresDB) ListRubyGemVersions(ctx context.Context, repoID, name string) ([]*models.RubyGem, error)

func (*PostgresDB) ListRubyGems

func (p *PostgresDB) ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)

func (*PostgresDB) ListSBOMReports

func (p *PostgresDB) ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)

ListSBOMReports lists all SBOM reports for a repository.

func (*PostgresDB) ListSBTArtifacts

func (p *PostgresDB) ListSBTArtifacts(ctx context.Context, repoID string) ([]*models.SBTArtifact, error)

func (*PostgresDB) ListSecretScanResults

func (p *PostgresDB) ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)

ListSecretScanResults lists all secret scan results for a repository.

func (*PostgresDB) ListStorageBackends

func (p *PostgresDB) ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)

ListStorageBackends lists all storage backends.

func (*PostgresDB) ListTokensByUser

func (p *PostgresDB) ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)

func (*PostgresDB) ListUnindexedDockerManifests added in v0.4.0

func (p *PostgresDB) ListUnindexedDockerManifests(ctx context.Context, repoID string, limit int) ([]*models.DockerGCManifest, error)

func (*PostgresDB) ListUnreferencedBlobs added in v0.2.0

func (p *PostgresDB) ListUnreferencedBlobs(ctx context.Context, minAge time.Duration, limit int) ([]string, error)

ListUnreferencedBlobs returns up to limit sha256 values of blobs rows that no package row references and that are older than minAge (so in-flight uploads, which create the blobs row before their referencing row, are never picked). Used to reclaim storage after repository deletion cascades its package rows.

func (*PostgresDB) ListUsers

func (p *PostgresDB) ListUsers(ctx context.Context, page, perPage int) ([]*models.User, int, error)

func (*PostgresDB) ListUsersByGroup

func (p *PostgresDB) ListUsersByGroup(ctx context.Context, groupID string) ([]*models.User, error)

func (*PostgresDB) ListVulnScanResults

func (p *PostgresDB) ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)

ListVulnScanResults lists all vulnerability scan results for a repository.

func (*PostgresDB) ListWebhookDeliveries

func (p *PostgresDB) ListWebhookDeliveries(ctx context.Context, webhookID string, limit int) ([]*models.WebhookDelivery, error)

ListWebhookDeliveries lists deliveries for a webhook.

func (*PostgresDB) ListWebhooks

func (p *PostgresDB) ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error)

ListWebhooks lists all webhooks for a repository (or global if repoID is empty).

func (*PostgresDB) ListWebhooksForEvent

func (p *PostgresDB) ListWebhooksForEvent(ctx context.Context, repoID, eventType string) ([]*models.Webhook, error)

ListWebhooksForEvent lists all enabled webhooks that are subscribed to an event.

func (*PostgresDB) MarkPackumentStale

func (p *PostgresDB) MarkPackumentStale(ctx context.Context, packageID string) error

func (*PostgresDB) MarkRepoStale

func (p *PostgresDB) MarkRepoStale(ctx context.Context, repositoryID string) error

MarkRepoStale marks repository metadata as stale for regeneration. NOTE: Currently only tracks staleness for RPM repos via rpm_repos table. DEB staleness tracking needs a separate mechanism (e.g., a stale flag on repositories table).

func (*PostgresDB) Migrate

func (p *PostgresDB) Migrate(ctx context.Context) error

Migrate runs database migrations.

func (*PostgresDB) Ping

func (p *PostgresDB) Ping(ctx context.Context) error

Ping checks if the database is accessible.

func (*PostgresDB) QuarantineArtifact

func (p *PostgresDB) QuarantineArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

QuarantineArtifact updates the quarantine status of an artifact.

func (*PostgresDB) QuarantineVulnArtifact

func (p *PostgresDB) QuarantineVulnArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error

QuarantineVulnArtifact updates the quarantine status of a vulnerable artifact.

func (*PostgresDB) ReconcileAllStorageUsage added in v0.4.0

func (p *PostgresDB) ReconcileAllStorageUsage(ctx context.Context) (int64, error)

ReconcileAllStorageUsage reconciles every repository (see ReconcileStorageUsage) and returns how many counters were corrected. Only one run is active at a time across replicas: when another holds the lock this returns 0, nil immediately.

func (*PostgresDB) ReconcileStorageUsage added in v0.4.0

func (p *PostgresDB) ReconcileStorageUsage(ctx context.Context, repoID string) (*models.StorageQuota, error)

ReconcileStorageUsage recomputes the usage counters of one repository from its package rows and returns the corrected quota (creating the quota row, unlimited, if it did not exist). The counters are maintained incrementally with asynchronous commits, so a crash can leave them off; this is the repair.

The recount is one statement over a single snapshot: an upload that has reserved but not yet inserted its row (or a delete that removed the row but not yet released) is not seen consistently, so the result can be off by those in-flight operations until the next reconcile.

func (*PostgresDB) RemoveBundleItem

func (p *PostgresDB) RemoveBundleItem(ctx context.Context, bundleID, sha256 string) error

func (*PostgresDB) RemoveGroupMember

func (p *PostgresDB) RemoveGroupMember(ctx context.Context, groupRepoID, memberRepoID string) error

func (*PostgresDB) RemoveOrgMember

func (p *PostgresDB) RemoveOrgMember(ctx context.Context, orgID, userID string) error

func (*PostgresDB) RemoveUserFromGroup

func (p *PostgresDB) RemoveUserFromGroup(ctx context.Context, userID, groupID string) error

func (*PostgresDB) RepairBootstrapAdmin added in v0.2.0

func (p *PostgresDB) RepairBootstrapAdmin(ctx context.Context, username string) (bool, error)

RepairBootstrapAdmin re-binds the named local admin user to admin-all when no principal at all holds that target, which is the state an interrupted bootstrap leaves behind. It never touches an instance where some principal already holds admin-all.

func (*PostgresDB) ReplaceGroupMembers added in v0.2.0

func (p *PostgresDB) ReplaceGroupMembers(ctx context.Context, groupRepoID string, memberIDs []string) error

ReplaceGroupMembers atomically replaces the member list of a group repository. An empty memberIDs slice clears the group.

func (*PostgresDB) ReserveStorageUsage added in v0.2.0

func (p *PostgresDB) ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)

ReserveStorageUsage atomically adds sizeBytes/artifactCount to the repository quota counters if doing so would not exceed the configured limits (a limit of 0 means unlimited). It returns false, nil when the quota would be exceeded.

func (*PostgresDB) RevokeToken

func (p *PostgresDB) RevokeToken(ctx context.Context, tokenID string) error

func (*PostgresDB) RpmPackageExists added in v0.2.0

func (p *PostgresDB) RpmPackageExists(ctx context.Context, repoID, name, version, release string, epoch int, arch string) (bool, error)

RpmPackageExists reports whether the repository already has a package with the NEVRA.

func (*PostgresDB) SealReleaseBundle added in v0.2.0

func (p *PostgresDB) SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time) (bool, error)

SealReleaseBundle moves a draft bundle to sealed with a conditional UPDATE (WHERE state = 'draft'), so concurrent item adds/seals cannot interleave. It reports whether the bundle was sealed; false means it was no longer a draft (or does not exist). A bundle with no items is never sealed.

func (*PostgresDB) SearchByProperty

func (p *PostgresDB) SearchByProperty(ctx context.Context, repoID, key, value string) ([]string, error)

SearchByProperty searches for artifacts by property key and value.

func (*PostgresDB) SearchCargoCrates

func (p *PostgresDB) SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)

func (*PostgresDB) SearchNuGetPackages

func (p *PostgresDB) SearchNuGetPackages(ctx context.Context, repoID, query string, skip, take int) ([]*models.NuGetPackage, int, error)

func (*PostgresDB) SearchRubyGems

func (p *PostgresDB) SearchRubyGems(ctx context.Context, repoID, query string) ([]*models.RubyGem, error)

func (*PostgresDB) SetArtifactProperties added in v0.2.0

func (p *PostgresDB) SetArtifactProperties(ctx context.Context, repoID, artifactID string, props map[string]string, replace bool) error

SetArtifactProperties upserts all props for an artifact in a single transaction. When replace is true the artifact's existing properties are deleted first, in the same transaction.

func (*PostgresDB) SetArtifactProperty

func (p *PostgresDB) SetArtifactProperty(ctx context.Context, repoID, artifactID, key, value string) error

SetArtifactProperty sets or updates an artifact property (UPSERT).

func (*PostgresDB) SetDebControlFields added in v0.2.0

func (p *PostgresDB) SetDebControlFields(ctx context.Context, packageID, maintainer, homepage string, fields map[string]string) error

SetDebControlFields stores the control stanza, maintainer and homepage of a deb package.

func (*PostgresDB) SetDockerManifestRefs added in v0.4.0

func (p *PostgresDB) SetDockerManifestRefs(ctx context.Context, repoID string, m *models.DockerGCManifest, refs models.DockerManifestRefs) error

func (*PostgresDB) SetLicenseScanQuarantine added in v0.4.0

func (p *PostgresDB) SetLicenseScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error

SetLicenseScanQuarantine quarantines (true) or approves (false) the artifact of exactly one license scan result (by ID, scoped to repoID). Approving records the decision for the licenses currently stored, so a later scan that finds the same licenses does not quarantine the artifact again; quarantining clears it. Returns ErrLicenseScanNotFound when nothing matched.

func (*PostgresDB) SetSystemSetting

func (p *PostgresDB) SetSystemSetting(ctx context.Context, key, value string) error

SetSystemSetting sets or updates a system setting.

func (*PostgresDB) SetVulnScanQuarantine added in v0.2.0

func (p *PostgresDB) SetVulnScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error

SetVulnScanQuarantine sets the quarantined flag of exactly one vuln scan result (by ID, scoped to repoID). Returns ErrVulnScanNotFound when nothing matched.

func (*PostgresDB) SyncSSOGroups

func (p *PostgresDB) SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error

func (*PostgresDB) SyncSSOPermissionsForGroup

func (p *PostgresDB) SyncSSOPermissionsForGroup(ctx context.Context, groupID string, targetIDs []string) error

func (*PostgresDB) TouchDockerBlob added in v0.4.0

func (p *PostgresDB) TouchDockerBlob(ctx context.Context, repoID, digest string) (bool, error)

TouchDockerBlob records that a client has just relied on the blob (HEAD probe, re-push, mount), so registry GC keeps it for its grace period. It reports false when the repository no longer has the blob.

func (*PostgresDB) UpdateBackupJob

func (p *PostgresDB) UpdateBackupJob(ctx context.Context, job *models.BackupJob) error

UpdateBackupJob updates an existing backup job.

func (*PostgresDB) UpdateBundlePromotion

func (p *PostgresDB) UpdateBundlePromotion(ctx context.Context, pr *models.BundlePromotion) error

func (*PostgresDB) UpdateCleanupPolicy

func (p *PostgresDB) UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error

UpdateCleanupPolicy updates an existing cleanup policy.

func (*PostgresDB) UpdateCleanupPolicyRunResult

func (p *PostgresDB) UpdateCleanupPolicyRunResult(ctx context.Context, id string, deletedCount int, runErr error) error

UpdateCleanupPolicyRunResult updates the run result of a cleanup policy.

func (*PostgresDB) UpdateDockerUploadOffset

func (p *PostgresDB) UpdateDockerUploadOffset(ctx context.Context, repositoryID, uploadUUID string, offset int64) error

func (*PostgresDB) UpdateGroup

func (p *PostgresDB) UpdateGroup(ctx context.Context, group *models.Group) error

func (*PostgresDB) UpdateLicensePolicy

func (p *PostgresDB) UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error

UpdateLicensePolicy updates a license policy.

func (*PostgresDB) UpdateLicenseScanResult

func (p *PostgresDB) UpdateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error

UpdateLicenseScanResult updates a license scan result.

func (*PostgresDB) UpdateNPMPackageLatestVersion

func (p *PostgresDB) UpdateNPMPackageLatestVersion(ctx context.Context, packageID, latestVersion string) error

func (*PostgresDB) UpdateOrgMemberRole

func (p *PostgresDB) UpdateOrgMemberRole(ctx context.Context, orgID, userID, role string) error

func (*PostgresDB) UpdateOrganization

func (p *PostgresDB) UpdateOrganization(ctx context.Context, org *models.Organization) error

func (*PostgresDB) UpdatePermissionTarget

func (p *PostgresDB) UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error

func (*PostgresDB) UpdatePromotionPipeline

func (p *PostgresDB) UpdatePromotionPipeline(ctx context.Context, pp *models.PromotionPipeline) error

func (*PostgresDB) UpdateReleaseBundle

func (p *PostgresDB) UpdateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error

func (*PostgresDB) UpdateRepository

func (p *PostgresDB) UpdateRepository(ctx context.Context, repo *models.Repository) error

func (*PostgresDB) UpdateRpmPackageExtra added in v0.4.0

func (p *PostgresDB) UpdateRpmPackageExtra(ctx context.Context, repoID, sha256 string, extra []byte) error

UpdateRpmPackageExtra replaces rpm_extra for the packages of a repo backed by the blob with the given sha256.

func (*PostgresDB) UpdateSSOProvider

func (p *PostgresDB) UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error

func (*PostgresDB) UpdateSecretScanResult

func (p *PostgresDB) UpdateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error

UpdateSecretScanResult updates a secret scan result.

func (*PostgresDB) UpdateSessionLastSeen

func (p *PostgresDB) UpdateSessionLastSeen(ctx context.Context, sessionID string, expiresAt time.Time) error

func (*PostgresDB) UpdateStorageBackend

func (p *PostgresDB) UpdateStorageBackend(ctx context.Context, backend *models.StorageBackend) error

UpdateStorageBackend updates a storage backend configuration.

func (*PostgresDB) UpdateStorageBackendStatus

func (p *PostgresDB) UpdateStorageBackendStatus(ctx context.Context, id, status string, message *string) error

UpdateStorageBackendStatus updates the status of a storage backend.

func (*PostgresDB) UpdateStorageQuota

func (p *PostgresDB) UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error

UpdateStorageQuota updates a storage quota.

func (*PostgresDB) UpdateTokenLastUsed

func (p *PostgresDB) UpdateTokenLastUsed(ctx context.Context, tokenID string) error

func (*PostgresDB) UpdateUser

func (p *PostgresDB) UpdateUser(ctx context.Context, user *models.User) error

func (*PostgresDB) UpdateUserSSO

func (p *PostgresDB) UpdateUserSSO(ctx context.Context, userID string, externalID, providerSlug string) error

func (*PostgresDB) UpdateVulnScanResult

func (p *PostgresDB) UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error

UpdateVulnScanResult updates a vulnerability scan result.

func (*PostgresDB) UpdateWebhook

func (p *PostgresDB) UpdateWebhook(ctx context.Context, wh *models.Webhook) error

UpdateWebhook updates an existing webhook.

func (*PostgresDB) UpdateWebhookDelivery

func (p *PostgresDB) UpdateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error

UpdateWebhookDelivery updates a webhook delivery record.

func (*PostgresDB) UpsertAIAnalysis

func (p *PostgresDB) UpsertAIAnalysis(ctx context.Context, analysis *models.AIAnalysis) error

UpsertAIAnalysis inserts or updates an AI analysis record.

AI analyses are stored across scan_jobs + artifact_refs + ai_results. analysis.ArtifactName/ArtifactVersion have no home in the schema (artifact_refs only tracks repository_id/ artifact_path/format) and are accepted here purely for API compatibility — they never round-trip through storage (verified: no caller reads them back off a persisted AIAnalysis). analysis.Status's "processing" value is mapped onto scan_jobs' CHECK-constrained "running" (see aiStatusToJob/FromJob).

func (*PostgresDB) UpsertBlob

func (p *PostgresDB) UpsertBlob(ctx context.Context, sha256, blobKey string, sizeBytes int64) (string, error)

UpsertBlob inserts a blob row keyed by sha256 and returns its id, using ON CONFLICT to handle concurrent uploads safely.

func (*PostgresDB) UpsertDockerTag

func (p *PostgresDB) UpsertDockerTag(ctx context.Context, tag *models.DockerTag) error

func (*PostgresDB) UpsertNPMDistTag

func (p *PostgresDB) UpsertNPMDistTag(ctx context.Context, t *models.NPMDistTag) (*models.NPMDistTag, error)

func (*PostgresDB) UpsertProxyCacheEntry

func (p *PostgresDB) UpsertProxyCacheEntry(ctx context.Context, entry *models.ProxyCacheEntry) error

func (*PostgresDB) UpsertRawArtifact

func (p *PostgresDB) UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error

UpsertRawArtifact inserts or updates a raw artifact.

func (*PostgresDB) UpsertRepoMetadata

func (p *PostgresDB) UpsertRepoMetadata(ctx context.Context, meta *models.RepoMetadata) error

func (*PostgresDB) WithBlobLock added in v0.2.0

func (p *PostgresDB) WithBlobLock(ctx context.Context, sha256 string, fn func(ctx context.Context) error) error

WithBlobLock runs fn inside a transaction holding a transaction-scoped advisory lock keyed on the blob sha256. Uploaders that create a reference to a blob and the garbage collector (DeleteBlobIfUnreferenced) serialize on the same lock, so a blob cannot be deleted between "ref count == 0" and the uploader's insert.

func (*PostgresDB) WithBlobLocks added in v0.2.0

func (p *PostgresDB) WithBlobLocks(ctx context.Context, shas []string, fn func(ctx context.Context) error) error

WithBlobLocks is WithBlobLock for several blobs at once: all locks are taken on ONE transaction connection, in sorted order (so two callers locking overlapping sets cannot deadlock each other), and held until fn returns. Taking them through nested WithBlobLock calls instead would pin one pooled connection per lock and let concurrent callers exhaust the pool.

func (*PostgresDB) YankCargoCrate

func (p *PostgresDB) YankCargoCrate(ctx context.Context, repoID, name, version string, yanked bool) error

func (*PostgresDB) YankRubyGem

func (p *PostgresDB) YankRubyGem(ctx context.Context, repoID, name, version string, yanked bool) error

type PostgresTx

type PostgresTx struct {
	// contains filtered or unexported fields
}

PostgresTx implements the Transaction interface for PostgreSQL.

func (*PostgresTx) Commit

func (t *PostgresTx) Commit() error

Commit commits the transaction.

func (*PostgresTx) ExecContext

func (t *PostgresTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*PostgresTx) QueryContext

func (t *PostgresTx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext executes a query that returns rows.

func (*PostgresTx) QueryRowContext

func (t *PostgresTx) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

QueryRowContext executes a query that returns a single row.

func (*PostgresTx) Rollback

func (t *PostgresTx) Rollback() error

Rollback rolls back the transaction.

type Transaction

type Transaction interface {
	// Commit commits the transaction
	Commit() error

	// Rollback rolls back the transaction
	Rollback() error

	// Exec executes a query without returning rows
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

	// Query executes a query that returns rows
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

	// QueryRow executes a query that returns a single row
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

Transaction defines the interface for database transactions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL