Documentation
¶
Index ¶
- Constants
- Variables
- func FlaggedArtifactPredicate(repoExpr, idExpr string) string
- func IsForeignKeyViolation(err error) bool
- func IsUniqueViolation(err error) bool
- func IsValidBlobSHA256(s string) bool
- func TrashRowsInTx(ctx context.Context, tx interface{ ... }, repoID string, kind models.TrashKind, ...) error
- func UniqueViolationConstraint(err error) string
- type AuditRetentionStore
- type BlobDeletion
- type BlobDeletionStore
- type BlobReplication
- type BlobReplicationBacklog
- type BlobReplicationState
- type BlobReplicationStore
- type BlobRow
- type BootstrapAdmin
- type ComponentListOptions
- type ComponentSearcher
- type Database
- type DatabaseConfig
- type DockerBlobImages
- type DockerBlobToucher
- type DockerBlobTrash
- type DockerCatalog
- type DockerGCStore
- type DockerUploadSweepStore
- type GomodAffectedRow
- type Migrator
- type PostgresDB
- func (p *PostgresDB) AddBlobReplicationProgress(ctx context.Context, copies, bytes int64) error
- func (p *PostgresDB) AddBundleItem(ctx context.Context, item *models.ReleaseBundleItem) error
- func (p *PostgresDB) AddBundleItems(ctx context.Context, bundleID string, items []*models.ReleaseBundleItem) error
- func (p *PostgresDB) AddGroupMember(ctx context.Context, groupRepoID, memberRepoID string, priority int) error
- func (p *PostgresDB) AddProjectMember(ctx context.Context, projectID, userID, role string) error
- func (p *PostgresDB) AddUserToGroup(ctx context.Context, userID, groupID string) error
- func (p *PostgresDB) ArtifactExists(ctx context.Context, sha256 string, repositoryID string) (bool, error)
- func (p *PostgresDB) ArtifactSecurity(ctx context.Context, repoID string, artifactIDs []string) (map[string]models.ArtifactSecurity, error)
- func (p *PostgresDB) AuthCacheGeneration() uint64
- func (p *PostgresDB) AuthCacheTTL() time.Duration
- func (p *PostgresDB) BeginBackupSnapshot(ctx context.Context, leaseTTL time.Duration) (SnapshotReader, error)
- func (p *PostgresDB) BeginStorageTierMove(ctx context.Context, m *models.StorageTierMove) (*models.StorageTierMove, bool, error)
- func (p *PostgresDB) BeginTx(ctx context.Context) (Transaction, error)
- func (p *PostgresDB) BlobDeletionDue(ctx context.Context, sha256, scope string) (bool, error)
- func (p *PostgresDB) BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
- func (p *PostgresDB) BlobReplicationBacklog(ctx context.Context, failingAttempts int) (BlobReplicationBacklog, error)
- func (p *PostgresDB) BlobReplicationReferenced(ctx context.Context, sha256 string) (bool, error)
- func (p *PostgresDB) BlobRowExists(ctx context.Context, sha256 string) (bool, error)
- func (p *PostgresDB) CargoIndexStamp(ctx context.Context, repoID, name string) (string, error)
- func (p *PostgresDB) ChangeProjectGroup(ctx context.Context, projectID, groupID, newRole string, createdBy *string, ...) error
- func (p *PostgresDB) ChangeProjectMember(ctx context.Context, projectID, userID, newRole string, guard ProjectRoleGuard) error
- func (p *PostgresDB) ChargeStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
- func (p *PostgresDB) ClaimBlobDeletions(ctx context.Context, limit int, claimFor time.Duration) ([]BlobDeletion, error)
- func (p *PostgresDB) ClaimBlobReplications(ctx context.Context, asOf time.Time, limit int, claimFor time.Duration) ([]BlobReplication, error)
- func (p *PostgresDB) ClaimPendingWebhookDeliveries(ctx context.Context, limit int, lease time.Duration) ([]*models.WebhookDelivery, error)
- func (p *PostgresDB) ClaimPresignedUpload(ctx context.Context, repoID, id string, lease time.Duration) (bool, error)
- func (p *PostgresDB) ClearGlobalGPGKey(ctx context.Context) error
- func (p *PostgresDB) ClearRepositoryGPGKey(ctx context.Context, repoID string) (bool, error)
- func (p *PostgresDB) Close() error
- func (p *PostgresDB) CompleteBlobReplication(ctx context.Context, sha256 string, version int64) (bool, error)
- func (p *PostgresDB) CondaRepodataStamp(ctx context.Context, repoID, platform string) (string, error)
- func (p *PostgresDB) ConsumeSAMLAssertion(ctx context.Context, providerSlug, assertionID string, expiresAt time.Time) (bool, error)
- func (p *PostgresDB) CountBlobDeletions(ctx context.Context) (int64, error)
- func (p *PostgresDB) CountBlobsOnStorageBackend(ctx context.Context, backendID string) (int64, error)
- func (p *PostgresDB) CountRepoPackageNames(ctx context.Context, repoIDs []string) (map[string]int64, error)
- func (p *PostgresDB) CountRepositories(ctx context.Context, formatFilter string) (int, error)
- func (p *PostgresDB) CountRepositoriesByProject(ctx context.Context, projectIDs []string) (map[string]int, error)
- func (p *PostgresDB) CountStorageTierMoves(ctx context.Context) (int64, error)
- func (p *PostgresDB) CountUsers(ctx context.Context) (int, error)
- func (p *PostgresDB) CreateBackupJob(ctx context.Context, job *models.BackupJob) error
- func (p *PostgresDB) CreateBootstrapAdmin(ctx context.Context, spec BootstrapAdmin) (bool, error)
- func (p *PostgresDB) CreateBundlePromotion(ctx context.Context, pr *models.BundlePromotion) error
- func (p *PostgresDB) CreateCargoCrate(ctx context.Context, crate *models.CargoCrate) error
- func (p *PostgresDB) CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
- func (p *PostgresDB) CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error
- func (p *PostgresDB) CreateCondaPackage(ctx context.Context, pkg *models.CondaPackage) error
- func (p *PostgresDB) CreateDebPackage(ctx context.Context, pkg *models.Component, distID, compID string) error
- func (p *PostgresDB) CreateDebianArchitecture(ctx context.Context, arch *models.DebianArchitecture) error
- func (p *PostgresDB) CreateDebianComponent(ctx context.Context, comp *models.DebianComponent) error
- func (p *PostgresDB) CreateDebianDistribution(ctx context.Context, dist *models.DebianDistribution) error
- func (p *PostgresDB) CreateDockerBlob(ctx context.Context, blob *models.DockerBlob) error
- func (p *PostgresDB) CreateDockerManifest(ctx context.Context, m *models.DockerManifest) error
- func (p *PostgresDB) CreateDockerUpload(ctx context.Context, upload *models.DockerUpload) error
- func (p *PostgresDB) CreateGPGKey(ctx context.Context, k *models.GPGKey) error
- func (p *PostgresDB) CreateGPGKeyIfNone(ctx context.Context, k *models.GPGKey) (bool, error)
- func (p *PostgresDB) CreateGoModule(ctx context.Context, mod *models.GoModule) error
- func (p *PostgresDB) CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)
- func (p *PostgresDB) CreateHelmChart(ctx context.Context, chart *models.HelmChart) error
- func (p *PostgresDB) CreateIvyArtifact(ctx context.Context, artifact *models.IvyArtifact) error
- func (p *PostgresDB) CreateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
- func (p *PostgresDB) CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
- func (p *PostgresDB) CreateMavenArtifact(ctx context.Context, a *models.MavenArtifact) error
- func (p *PostgresDB) CreateNPMPackage(ctx context.Context, pkg *models.NPMPackage) (*models.NPMPackage, error)
- func (p *PostgresDB) CreateNPMVersion(ctx context.Context, v *models.NPMVersion) (*models.NPMVersion, error)
- func (p *PostgresDB) CreateNuGetPackage(ctx context.Context, pkg *models.NuGetPackage) error
- func (p *PostgresDB) CreatePackageDelta(ctx context.Context, d *models.PackageDelta) error
- func (p *PostgresDB) CreatePermissionAssignment(ctx context.Context, assignment *models.PermissionAssignment) error
- func (p *PostgresDB) CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)
- func (p *PostgresDB) CreatePresignedUpload(ctx context.Context, u *models.PresignedUpload) error
- func (p *PostgresDB) CreatePresignedUploadCapped(ctx context.Context, u *models.PresignedUpload, maxPending int) error
- func (p *PostgresDB) CreateProject(ctx context.Context, project *models.Project) error
- func (p *PostgresDB) CreateProjectRepository(ctx context.Context, repo *models.Repository, memberIDs []string, ...) error
- func (p *PostgresDB) CreateProjectToken(ctx context.Context, spec ProjectTokenSpec) (*models.Token, error)
- func (p *PostgresDB) CreatePromotionPipeline(ctx context.Context, pp *models.PromotionPipeline) error
- func (p *PostgresDB) CreatePyPIPackage(ctx context.Context, pkg *models.PyPIPackage) error
- func (p *PostgresDB) CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error
- func (p *PostgresDB) CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
- func (p *PostgresDB) CreateRepository(ctx context.Context, repo *models.Repository) error
- func (p *PostgresDB) CreateRepositoryWithMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
- func (p *PostgresDB) CreateRpmPackage(ctx context.Context, pkg *models.Component) error
- func (p *PostgresDB) CreateRubyGem(ctx context.Context, gem *models.RubyGem) error
- func (p *PostgresDB) CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error
- func (p *PostgresDB) CreateSBTArtifact(ctx context.Context, artifact *models.SBTArtifact) error
- func (p *PostgresDB) CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
- func (p *PostgresDB) CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error
- func (p *PostgresDB) CreateSession(ctx context.Context, session *models.Session) (*models.Session, error)
- func (p *PostgresDB) CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
- func (p *PostgresDB) CreateStoragePolicy(ctx context.Context, pol *models.StoragePolicy) error
- func (p *PostgresDB) CreateStorageTier(ctx context.Context, t *models.StorageTier) error
- func (p *PostgresDB) CreateSystemSettingIfAbsent(ctx context.Context, key, value string) (bool, error)
- func (p *PostgresDB) CreateToken(ctx context.Context, token *models.Token) (*models.Token, error)
- func (p *PostgresDB) CreateUser(ctx context.Context, user *models.User) (*models.User, error)
- func (p *PostgresDB) CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
- func (p *PostgresDB) CreateWebhook(ctx context.Context, wh *models.Webhook) error
- func (p *PostgresDB) CreateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error
- func (p *PostgresDB) DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
- func (p *PostgresDB) DeleteArtifactProperty(ctx context.Context, repoID, artifactID, key string) error
- func (p *PostgresDB) DeleteBlobDeletion(ctx context.Context, sha256, scope string) error
- func (p *PostgresDB) DeleteBlobIfUnreferenced(ctx context.Context, sha256 string) (bool, error)
- func (p *PostgresDB) DeleteCleanupPolicy(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteComponent(ctx context.Context, componentID string) error
- func (p *PostgresDB) DeleteConanPackage(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteCondaPackage(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteDeclarativeObject(ctx context.Context, kind, name string) (bool, error)
- func (p *PostgresDB) DeleteDockerBlob(ctx context.Context, repoID, digest string) error
- func (p *PostgresDB) DeleteDockerBlobsForGC(ctx context.Context, repoID string, digests []string, grace time.Duration) ([]*models.DockerGCBlob, error)
- func (p *PostgresDB) DeleteDockerManifest(ctx context.Context, repoID, image, digest string) error
- func (p *PostgresDB) DeleteDockerManifestsForGC(ctx context.Context, repoID string, ids []string, grace time.Duration) ([]*models.DockerGCManifest, error)
- func (p *PostgresDB) DeleteDockerTag(ctx context.Context, repoID, image, name string) error
- func (p *PostgresDB) DeleteDockerTagsByDigest(ctx context.Context, repoID, image, digest string) error
- func (p *PostgresDB) DeleteDockerUpload(ctx context.Context, repositoryID, uploadUUID string) error
- func (p *PostgresDB) DeleteExpiredProxyCacheEntries(ctx context.Context) (int64, error)
- func (p *PostgresDB) DeleteGPGKey(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteGroup(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteHelmChart(ctx context.Context, repoID, name, version string) error
- func (p *PostgresDB) DeleteIvyArtifact(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteLicensePolicy(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteMavenArtifact(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteNPMDistTag(ctx context.Context, packageID, tag string) error
- func (p *PostgresDB) DeleteNPMPackage(ctx context.Context, packageID string) error
- func (p *PostgresDB) DeleteNPMVersion(ctx context.Context, packageID, version string) error
- func (p *PostgresDB) DeleteNuGetPackage(ctx context.Context, repoID, packageID, version string) error
- func (p *PostgresDB) DeleteOtherSessionsByUser(ctx context.Context, userID, keepTokenHash string) error
- func (p *PostgresDB) DeletePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error
- func (p *PostgresDB) DeletePermissionTarget(ctx context.Context, id string) error
- func (p *PostgresDB) DeletePresignedUpload(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteProject(ctx context.Context, id string) error
- func (p *PostgresDB) DeletePromotionPipeline(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteProxyCacheEntry(ctx context.Context, repoID, cacheKey string) error
- func (p *PostgresDB) DeletePyPIPackage(ctx context.Context, repoID, name, version, filename string) error
- func (p *PostgresDB) DeleteRawArtifact(ctx context.Context, repoID, path string) error
- func (p *PostgresDB) DeleteReleaseBundle(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteRepository(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteRepositoryDependencyTrack(ctx context.Context, repoID string) (bool, error)
- func (p *PostgresDB) DeleteSBOMReportInRepo(ctx context.Context, repoID, id string) (string, error)
- func (p *PostgresDB) DeleteSBTArtifact(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteSSOProvider(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteSession(ctx context.Context, tokenHash string) error
- func (p *PostgresDB) DeleteSessionsByUser(ctx context.Context, userID string) error
- func (p *PostgresDB) DeleteStaleDockerUploads(ctx context.Context, cutoff time.Time) ([]string, error)
- func (p *PostgresDB) DeleteStorageBackend(ctx context.Context, id string) error
- func (p *PostgresDB) DeleteStoragePolicy(ctx context.Context, id string) (bool, error)
- func (p *PostgresDB) DeleteStorageTierIfUnused(ctx context.Context, tierID string) (string, error)
- func (p *PostgresDB) DeleteUnreferencedInvalidBlobRow(ctx context.Context, id string) (bool, error)
- func (p *PostgresDB) DeleteUser(ctx context.Context, id string) (bool, error)
- func (p *PostgresDB) DeleteVEXStatement(ctx context.Context, repoID, id string) error
- func (p *PostgresDB) DeleteVulnScanResult(ctx context.Context, repoID, id string) error
- func (p *PostgresDB) DeleteWebhook(ctx context.Context, id string) error
- func (p *PostgresDB) DockerBlobInTrash(ctx context.Context, repoID, digest string) (bool, error)
- func (p *PostgresDB) DockerBlobVisible(ctx context.Context, repoID, image, digest string) (bool, error)
- func (p *PostgresDB) EmptySHA256BlobID(ctx context.Context) (string, error)
- func (p *PostgresDB) EnqueueBlobDeletion(ctx context.Context, sha256, scope string) error
- func (p *PostgresDB) EnqueueBlobReplication(ctx context.Context, sha256, op string) error
- func (p *PostgresDB) EnsureBlob(ctx context.Context, sha256, mediaType string, size int64) (string, error)
- func (p *PostgresDB) ExistingPresignedUploadIDs(ctx context.Context, ids []string) ([]string, error)
- func (p *PostgresDB) ExtendPresignedUploadExpiry(ctx context.Context, id string, expiresAt time.Time) error
- func (p *PostgresDB) FailBlobReplication(ctx context.Context, sha256 string, version int64, lastError string, ...) (bool, error)
- func (p *PostgresDB) FailStorageTierMove(ctx context.Context, sha256, message string) error
- func (p *PostgresDB) FindConanPackageBySHA1(ctx context.Context, repoID, sha1 string) (*models.ConanPackage, error)
- func (p *PostgresDB) FinishReplicationVerify(ctx context.Context, result json.RawMessage) error
- func (p *PostgresDB) FinishStorageTierMove(ctx context.Context, sha256 string) error
- func (p *PostgresDB) FlipBlobPlacement(ctx context.Context, sha256, from, to string, ...) (models.FlipOutcome, error)
- func (p *PostgresDB) GetAIAnalysis(ctx context.Context, repoID, artifactID string) (*models.AIAnalysis, error)
- func (p *PostgresDB) GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)
- func (p *PostgresDB) GetBlobPlacement(ctx context.Context, sha256 string) (string, int64, bool, error)
- func (p *PostgresDB) GetBlobReplication(ctx context.Context, sha256 string) (*BlobReplication, error)
- func (p *PostgresDB) GetBlobReplicationState(ctx context.Context) (BlobReplicationState, error)
- func (p *PostgresDB) GetBundleItem(ctx context.Context, bundleID, sha256 string) (*models.ReleaseBundleItem, error)
- func (p *PostgresDB) GetCargoCrate(ctx context.Context, repoID, name, version string) (*models.CargoCrate, error)
- func (p *PostgresDB) GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)
- func (p *PostgresDB) GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
- func (p *PostgresDB) GetComponentByID(ctx context.Context, id string) (*models.Component, error)
- func (p *PostgresDB) GetComponentBySHA256(ctx context.Context, repoID, sha256 string) (*models.Component, error)
- func (p *PostgresDB) GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)
- func (p *PostgresDB) GetConanPackage(ctx context.Context, repoID string, key models.ConanFileKey) (*models.ConanPackage, error)
- func (p *PostgresDB) GetCondaPackageFile(ctx context.Context, ...) (*models.CondaPackage, error)
- func (p *PostgresDB) GetDB() *sql.DB
- func (p *PostgresDB) GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)
- func (p *PostgresDB) GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)
- func (p *PostgresDB) GetDebianArchitecturesByDist(ctx context.Context, distID string) ([]models.DebianArchitecture, error)
- func (p *PostgresDB) GetDebianComponentsByDist(ctx context.Context, distID string) ([]models.DebianComponent, error)
- func (p *PostgresDB) GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)
- func (p *PostgresDB) GetDebianPackageByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
- func (p *PostgresDB) GetDebianPackagesByDistComp(ctx context.Context, repoID string, dist string, comp string, arch string) ([]models.Component, error)
- func (p *PostgresDB) GetDependencyTrackPush(ctx context.Context, repoID, artifactID string) (*models.DependencyTrackPush, error)
- func (p *PostgresDB) GetDockerBlob(ctx context.Context, repoID, digest string) (*models.DockerBlob, error)
- func (p *PostgresDB) GetDockerManifest(ctx context.Context, repoID, image, digest string) (*models.DockerManifest, error)
- func (p *PostgresDB) GetDockerTag(ctx context.Context, repoID, image, name string) (*models.DockerTag, error)
- func (p *PostgresDB) GetDockerUpload(ctx context.Context, repositoryID, uploadUUID string) (*models.DockerUpload, error)
- func (p *PostgresDB) GetGPGKey(ctx context.Context, id string) (*models.GPGKey, error)
- func (p *PostgresDB) GetGPGKeyByFingerprint(ctx context.Context, fingerprint string) (*models.GPGKey, error)
- func (p *PostgresDB) GetGoModule(ctx context.Context, repoID, modulePath, version string) (*models.GoModule, error)
- func (p *PostgresDB) GetGroupByID(ctx context.Context, id string) (*models.Group, error)
- func (p *PostgresDB) GetGroupByName(ctx context.Context, name string) (*models.Group, error)
- func (p *PostgresDB) GetGroupMetadataState(ctx context.Context, groupID string) (*models.GroupMetadataState, error)
- func (p *PostgresDB) GetGroupPackageOwner(ctx context.Context, groupID, path string) (string, bool, error)
- func (p *PostgresDB) GetHelmChart(ctx context.Context, repoID, name, version string) (*models.HelmChart, error)
- func (p *PostgresDB) GetIvyArtifact(ctx context.Context, ...) (*models.IvyArtifact, error)
- func (p *PostgresDB) GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)
- func (p *PostgresDB) GetLatestSnapshotFile(ctx context.Context, ...) (*models.MavenArtifact, error)
- func (p *PostgresDB) GetLicensePolicy(ctx context.Context, id string) (*models.LicensePolicy, error)
- func (p *PostgresDB) GetLicenseScanResult(ctx context.Context, repoID, artifactID string) (*models.LicenseScanResult, error)
- func (p *PostgresDB) GetLicenseScanResultByID(ctx context.Context, repoID, id string) (*models.LicenseScanResult, error)
- func (p *PostgresDB) GetMavenArtifactByPath(ctx context.Context, repoID, path string) (*models.MavenArtifact, error)
- func (p *PostgresDB) GetMavenArtifactsByGAV(ctx context.Context, repoID, groupID, artifactID, version string) ([]*models.MavenArtifact, error)
- func (p *PostgresDB) GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)
- func (p *PostgresDB) GetNPMPackageByName(ctx context.Context, repoID, fullName string) (*models.NPMPackage, error)
- func (p *PostgresDB) GetNPMVersion(ctx context.Context, packageID, version string) (*models.NPMVersion, error)
- func (p *PostgresDB) GetNPMVersionStates(ctx context.Context, packageID string) ([]models.NPMVersionState, error)
- func (p *PostgresDB) GetNPMVersionsByPackage(ctx context.Context, packageID string) ([]*models.NPMVersion, error)
- func (p *PostgresDB) GetNuGetPackage(ctx context.Context, repoID, packageID, version string) (*models.NuGetPackage, error)
- func (p *PostgresDB) GetOrCreateDebianArchitecture(ctx context.Context, distID, name string) (*models.DebianArchitecture, error)
- func (p *PostgresDB) GetOrCreateDebianComponent(ctx context.Context, distID, name string) (*models.DebianComponent, error)
- func (p *PostgresDB) GetOrCreateDebianDistribution(ctx context.Context, repoID, name string) (*models.DebianDistribution, error)
- func (p *PostgresDB) GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)
- func (p *PostgresDB) GetOrCreatePermissionAssignment(ctx context.Context, targetID, principalType, principalID string) error
- func (p *PostgresDB) GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
- func (p *PostgresDB) GetPackageDelta(ctx context.Context, repoID, fromSHA256, toSHA256 string) (*models.PackageDelta, error)
- func (p *PostgresDB) GetPasswordExpiry(ctx context.Context, userID string) (*time.Time, error)
- func (p *PostgresDB) GetPermissionTargetByID(ctx context.Context, id string) (*models.PermissionTarget, error)
- func (p *PostgresDB) GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
- func (p *PostgresDB) GetPermissionTargetsForPrincipal(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)
- func (p *PostgresDB) GetPermissionTargetsForPrincipalUncached(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)
- func (p *PostgresDB) GetPresignedUpload(ctx context.Context, repoID, id string) (*models.PresignedUpload, error)
- func (p *PostgresDB) GetProject(ctx context.Context, id string) (*models.Project, error)
- func (p *PostgresDB) GetProjectByName(ctx context.Context, name string) (*models.Project, error)
- func (p *PostgresDB) GetProjectGroup(ctx context.Context, projectID, groupID string) (*models.ProjectGroup, error)
- func (p *PostgresDB) GetProjectMember(ctx context.Context, projectID, userID string) (*models.ProjectMember, error)
- func (p *PostgresDB) GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
- func (p *PostgresDB) GetProjectUsage(ctx context.Context, projectID string) (*models.ProjectUsage, error)
- func (p *PostgresDB) GetPromotionPipelineByID(ctx context.Context, id string) (*models.PromotionPipeline, error)
- func (p *PostgresDB) GetPromotionPipelineByName(ctx context.Context, name string) (*models.PromotionPipeline, error)
- func (p *PostgresDB) GetProxyCacheEntry(ctx context.Context, repoID, cacheKey string) (*models.ProxyCacheEntry, error)
- func (p *PostgresDB) GetPyPIPackageByFilename(ctx context.Context, repoID, filename string) (*models.PyPIPackage, error)
- func (p *PostgresDB) GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)
- func (p *PostgresDB) GetRawArtifact(ctx context.Context, repoID, path string) (*models.RawArtifact, error)
- func (p *PostgresDB) GetReleaseBundle(ctx context.Context, name, version string) (*models.ReleaseBundle, error)
- func (p *PostgresDB) GetReleaseBundleByID(ctx context.Context, id string) (*models.ReleaseBundle, error)
- func (p *PostgresDB) GetRepoComponentBlob(ctx context.Context, repoID, id string) (*models.ComponentBlob, error)
- func (p *PostgresDB) GetRepoComponentDetail(ctx context.Context, repoID, id string) (*models.ComponentDetail, error)
- func (p *PostgresDB) GetRepoMetadataByPath(ctx context.Context, repositoryID string, path string) (*models.RepoMetadata, error)
- func (p *PostgresDB) GetRepoMetadataByRepo(ctx context.Context, repositoryID string) ([]models.RepoMetadata, error)
- func (p *PostgresDB) GetRepositoryAttestationAttach(ctx context.Context, repoID string) (bool, error)
- func (p *PostgresDB) GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
- func (p *PostgresDB) GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
- func (p *PostgresDB) GetRepositoryByNameUncached(ctx context.Context, name string) (*models.Repository, error)
- func (p *PostgresDB) GetRepositoryDependencyTrack(ctx context.Context, repoID string) (*models.RepositoryDependencyTrack, error)
- func (p *PostgresDB) GetRepositoryUsage(ctx context.Context, repoID string) (*models.RepositoryUsage, error)
- func (p *PostgresDB) GetRpmPackageByID(ctx context.Context, id string) (*models.RpmPackage, error)
- func (p *PostgresDB) GetRubyGem(ctx context.Context, repoID, name, version, platform string) (*models.RubyGem, error)
- func (p *PostgresDB) GetSBOMReportByID(ctx context.Context, repoID, id string) (*models.SBOMReport, error)
- func (p *PostgresDB) GetSBTArtifact(ctx context.Context, repoID, groupID, artifactID, version, filename string) (*models.SBTArtifact, error)
- func (p *PostgresDB) GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)
- func (p *PostgresDB) GetSecretScanResult(ctx context.Context, repoID, artifactID string) (*models.SecretScanResult, error)
- func (p *PostgresDB) GetSessionByTokenHash(ctx context.Context, hash string) (*models.Session, error)
- func (p *PostgresDB) GetSessionSSO(ctx context.Context, tokenHash string) (*models.SessionSSO, error)
- func (p *PostgresDB) GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)
- func (p *PostgresDB) GetStoragePolicy(ctx context.Context, id string) (*models.StoragePolicy, error)
- func (p *PostgresDB) GetStorageTierByName(ctx context.Context, name string) (*models.StorageTier, error)
- func (p *PostgresDB) GetSystemSetting(ctx context.Context, key string) (string, error)
- func (p *PostgresDB) GetTokenByHash(ctx context.Context, hash string) (*models.Token, error)
- func (p *PostgresDB) GetTokenByHashUncached(ctx context.Context, hash string) (*models.Token, error)
- func (p *PostgresDB) GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)
- func (p *PostgresDB) GetTrashItem(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
- func (p *PostgresDB) GetUserByEmail(ctx context.Context, email string) (*models.User, error)
- func (p *PostgresDB) GetUserByExternalID(ctx context.Context, externalID, providerSlug string) (*models.User, error)
- func (p *PostgresDB) GetUserByID(ctx context.Context, id string) (*models.User, error)
- func (p *PostgresDB) GetUserByIDUncached(ctx context.Context, id string) (*models.User, error)
- func (p *PostgresDB) GetUserByUsername(ctx context.Context, username string) (*models.User, error)
- func (p *PostgresDB) GetVulnScanResult(ctx context.Context, repoID, artifactID string) (*models.VulnScanResult, error)
- func (p *PostgresDB) GetVulnScanResultByID(ctx context.Context, repoID, id string) (*models.VulnScanResult, error)
- func (p *PostgresDB) GetWebhook(ctx context.Context, id string) (*models.Webhook, error)
- func (p *PostgresDB) HelmIndexStamp(ctx context.Context, repoID string) (string, error)
- func (p *PostgresDB) IncrementCargoDownloadCount(ctx context.Context, repoID, name, version string) error
- func (p *PostgresDB) IncrementNuGetDownloadCount(ctx context.Context, repoID, packageID, version string) error
- func (p *PostgresDB) InsertAuditLog(ctx context.Context, event *models.AuditLog) error
- func (p *PostgresDB) InsertRawArtifactIfAbsent(ctx context.Context, artifact *models.RawArtifact) (bool, error)
- func (p *PostgresDB) IsArtifactQuarantined(ctx context.Context, repoID string, keys []string) (bool, error)
- func (p *PostgresDB) LatestFinishedDependencyTrackPush(ctx context.Context) (*models.DependencyTrackLastPush, error)
- func (p *PostgresDB) LinkDockerBlob(ctx context.Context, repoID, image, digest string) error
- func (p *PostgresDB) ListAIAnalyses(ctx context.Context, repoID string, status string, licenseReviewOnly bool, ...) ([]*models.AIAnalysis, int, error)
- func (p *PostgresDB) ListAllCondaPackages(ctx context.Context, repoID string) ([]*models.CondaPackage, error)
- func (p *PostgresDB) ListAllNPMPackages(ctx context.Context, repoID string) ([]*models.NPMPackage, error)
- func (p *PostgresDB) ListAllProjects(ctx context.Context) ([]*models.Project, error)
- func (p *PostgresDB) ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
- func (p *PostgresDB) ListAllTokens(ctx context.Context, page, perPage int) ([]*models.Token, int, error)
- func (p *PostgresDB) ListArtifactProperties(ctx context.Context, repoID, artifactID string) (map[string]string, error)
- func (p *PostgresDB) ListAuditLogs(ctx context.Context, params models.AuditListParams) (*models.AuditPage, error)
- func (p *PostgresDB) ListBackupJobs(ctx context.Context, limit int) ([]*models.BackupJob, error)
- func (p *PostgresDB) ListBlobRefs(ctx context.Context, shas []string) (map[string][]models.BlobRef, error)
- func (p *PostgresDB) ListBlobSHAs(ctx context.Context, after string, limit int) ([]string, error)
- func (p *PostgresDB) ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)
- func (p *PostgresDB) ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)
- func (p *PostgresDB) ListCargoCrateVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)
- func (p *PostgresDB) ListCargoIndexVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)
- func (p *PostgresDB) ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)
- func (p *PostgresDB) ListComponentsByRepo(ctx context.Context, repoID, formatFilter string, page, limit int) ([]*models.Component, int, error)
- func (p *PostgresDB) ListConanPackages(ctx context.Context, repoID string) ([]*models.ConanPackage, error)
- func (p *PostgresDB) ListConanRecipeFiles(ctx context.Context, repoID, name, version, userChannel string) ([]*models.ConanPackage, error)
- func (p *PostgresDB) ListConanRecipes(ctx context.Context, repoID string) ([]models.ConanRecipe, error)
- func (p *PostgresDB) ListCondaPackages(ctx context.Context, repoID, platform string) ([]*models.CondaPackage, error)
- func (p *PostgresDB) ListDebPackageEntries(ctx context.Context, repoID, dist, comp, arch string) ([]models.DebPackageEntry, error)
- func (p *PostgresDB) ListDebPackagesByRepo(ctx context.Context, repoID string) ([]*models.DebPackage, error)
- func (p *PostgresDB) ListDeclarativeObjects(ctx context.Context) ([]models.DeclarativeObject, error)
- func (p *PostgresDB) ListDependencyTrackPushes(ctx context.Context, repoID string, limit int) ([]*models.DependencyTrackPush, error)
- func (p *PostgresDB) ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)
- func (p *PostgresDB) ListDockerCatalog(ctx context.Context, after string, limit int) ([]*models.DockerCatalogEntry, error)
- func (p *PostgresDB) ListDockerGCBlobs(ctx context.Context, repoID string, grace time.Duration, ...) ([]*models.DockerGCBlob, error)
- func (p *PostgresDB) ListDockerGCManifests(ctx context.Context, repoID string, grace time.Duration) ([]*models.DockerGCManifest, error)
- func (p *PostgresDB) ListDockerManifestsByRepo(ctx context.Context, repoID string) ([]*models.DockerManifest, error)
- func (p *PostgresDB) ListDockerManifestsBySubject(ctx context.Context, repoID, image, subjectDigest string) ([]*models.DockerManifest, error)
- func (p *PostgresDB) ListDockerTags(ctx context.Context, repoID, image, last string, n int) ([]*models.DockerTag, error)
- func (p *PostgresDB) ListDockerTagsByRepo(ctx context.Context, repoID string, limit int) ([]*models.DockerTag, error)
- func (p *PostgresDB) ListEnabledCleanupPolicies(ctx context.Context) ([]*models.CleanupPolicy, error)
- func (p *PostgresDB) ListEnabledSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
- func (p *PostgresDB) ListExpiredPresignedUploads(ctx context.Context, limit int) ([]string, error)
- func (p *PostgresDB) ListExpiredTrash(ctx context.Context, limit int) ([]models.TrashRef, error)
- func (p *PostgresDB) ListGPGKeyAssignments(ctx context.Context) ([]models.GPGKeyAssignment, error)
- func (p *PostgresDB) ListGPGKeys(ctx context.Context) ([]*models.GPGKey, error)
- func (p *PostgresDB) ListGlobalLicensePolicies(ctx context.Context) ([]*models.LicensePolicy, error)
- func (p *PostgresDB) ListGoModuleVersions(ctx context.Context, repoID, modulePath string) ([]*models.GoModule, error)
- func (p *PostgresDB) ListGoModulesByRepo(ctx context.Context, repoID string) ([]*models.GoModule, error)
- func (p *PostgresDB) ListGomodAffectedRows(ctx context.Context) ([]GomodAffectedRow, error)
- func (p *PostgresDB) ListGomodSiblingZipKeys(ctx context.Context) ([]string, error)
- func (p *PostgresDB) ListGroupMemberRepositories(ctx context.Context, groupRepoID string) ([]*models.Repository, error)
- func (p *PostgresDB) ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
- func (p *PostgresDB) ListGroups(ctx context.Context) ([]*models.Group, error)
- func (p *PostgresDB) ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)
- func (p *PostgresDB) ListGroupsByUserUncached(ctx context.Context, userID string) ([]*models.Group, error)
- func (p *PostgresDB) ListGroupsOfMember(ctx context.Context, memberRepoID string) ([]*models.Repository, error)
- func (p *PostgresDB) ListHelmCharts(ctx context.Context, repoID string) ([]*models.HelmChart, error)
- func (p *PostgresDB) ListIvyArtifacts(ctx context.Context, repoID string) ([]*models.IvyArtifact, error)
- func (p *PostgresDB) ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)
- func (p *PostgresDB) ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)
- func (p *PostgresDB) ListMavenArtifactsByRepo(ctx context.Context, repoID string) ([]*models.MavenArtifact, error)
- func (p *PostgresDB) ListMavenGARefs(ctx context.Context, repoID, groupID, artifactID string) (*models.MavenGARefs, error)
- func (p *PostgresDB) ListMetadataGroupsOfMember(ctx context.Context, memberRepoID string) ([]string, error)
- func (p *PostgresDB) ListNPMVersionsByRepo(ctx context.Context, repoID string) ([]*models.NPMVersion, error)
- func (p *PostgresDB) ListNuGetPackageVersions(ctx context.Context, repoID, packageID string) ([]*models.NuGetPackage, error)
- func (p *PostgresDB) ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)
- func (p *PostgresDB) ListPackageDeltas(ctx context.Context, repoID, toSHA256 string) ([]*models.PackageDelta, error)
- func (p *PostgresDB) ListPermissionAssignments(ctx context.Context) ([]*models.PermissionAssignment, error)
- func (p *PostgresDB) ListPermissionAssignmentsForTarget(ctx context.Context, targetID string) ([]models.PermissionAssignmentView, error)
- func (p *PostgresDB) ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)
- func (p *PostgresDB) ListProjectCleanupPolicies(ctx context.Context, projectID string) ([]*models.CleanupPolicy, error)
- func (p *PostgresDB) ListProjectCleanupRepositories(ctx context.Context, projectID string) ([]string, error)
- func (p *PostgresDB) ListProjectGrantsByUser(ctx context.Context, userID string) ([]*models.ProjectGrant, error)
- func (p *PostgresDB) ListProjectGroups(ctx context.Context, projectID string) ([]*models.ProjectGroup, error)
- func (p *PostgresDB) ListProjectMembers(ctx context.Context, projectID string) ([]*models.ProjectMember, error)
- func (p *PostgresDB) ListProjectRepositories(ctx context.Context, projectID string, page, limit int) ([]*models.Repository, int, error)
- func (p *PostgresDB) ListProjectStats(ctx context.Context, projectIDs []string) (map[string]*models.ProjectStats, error)
- func (p *PostgresDB) ListProjectTokens(ctx context.Context, projectID string, createdBy *string) ([]*models.Token, error)
- func (p *PostgresDB) ListProjects(ctx context.Context, userID string) ([]*models.Project, error)
- func (p *PostgresDB) ListPromotionCandidates(ctx context.Context, backendIDs []string, after string, limit int) ([]models.BlobFacts, error)
- func (p *PostgresDB) ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)
- func (p *PostgresDB) ListPublicRepositoryNames(ctx context.Context) ([]string, error)
- func (p *PostgresDB) ListPyPIPackageNames(ctx context.Context, repoID string) ([]string, error)
- func (p *PostgresDB) ListPyPIPackageVersions(ctx context.Context, repoID, name string) ([]*models.PyPIPackage, error)
- func (p *PostgresDB) ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)
- func (p *PostgresDB) ListQuotaOverview(ctx context.Context, params models.QuotaListParams) ([]*models.QuotaOverview, int, error)
- func (p *PostgresDB) ListRawArtifacts(ctx context.Context, repoID, prefix string) ([]*models.RawArtifact, error)
- func (p *PostgresDB) ListRecentPackages(ctx context.Context, repoIDs []string, limit int) ([]models.RecentPackage, error)
- func (p *PostgresDB) ListRecoverableStorageTierMoves(ctx context.Context, maxAttempts int, retryAfter time.Duration, limit int) ([]*models.StorageTierMove, error)
- func (p *PostgresDB) ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)
- func (p *PostgresDB) ListRepoPackageRollup(ctx context.Context, opts models.PackageRollupOptions) ([]models.PackageRollup, int, error)
- func (p *PostgresDB) ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)
- func (p *PostgresDB) ListRepositoriesForGPGKey(ctx context.Context, keyID string) ([]models.GPGSigningRepo, error)
- func (p *PostgresDB) ListRpmPackagesForMetadata(ctx context.Context, repoID string) ([]pkgrpm.Package, error)
- func (p *PostgresDB) ListRubyGemSpecs(ctx context.Context, repoID string) ([]*models.RubyGem, error)
- func (p *PostgresDB) ListRubyGemVersions(ctx context.Context, repoID, name string) ([]*models.RubyGem, error)
- func (p *PostgresDB) ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)
- func (p *PostgresDB) ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)
- func (p *PostgresDB) ListSBTArtifacts(ctx context.Context, repoID string) ([]*models.SBTArtifact, error)
- func (p *PostgresDB) ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)
- func (p *PostgresDB) ListSecurityFindings(ctx context.Context, params models.FindingListParams) (*models.FindingPage, error)
- func (p *PostgresDB) ListSigningRepositoriesWithoutKey(ctx context.Context) ([]models.GPGSigningRepo, error)
- func (p *PostgresDB) ListStaleMetadataGroups(ctx context.Context) ([]string, error)
- func (p *PostgresDB) ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)
- func (p *PostgresDB) ListStoragePolicies(ctx context.Context) ([]*models.StoragePolicy, error)
- func (p *PostgresDB) ListStorageQuotas(ctx context.Context) ([]*models.StorageQuota, error)
- func (p *PostgresDB) ListStorageTierMoves(ctx context.Context, limit int) ([]*models.StorageTierMove, error)
- func (p *PostgresDB) ListStorageTiers(ctx context.Context) ([]*models.StorageTier, error)
- func (p *PostgresDB) ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)
- func (p *PostgresDB) ListTrash(ctx context.Context, f models.TrashFilter) ([]*models.TrashItem, int, error)
- func (p *PostgresDB) ListUnifiedTokens(ctx context.Context, params models.TokenListParams) ([]*models.TokenListItem, int, error)
- func (p *PostgresDB) ListUnindexedDockerManifests(ctx context.Context, repoID string, limit int) ([]*models.DockerGCManifest, error)
- func (p *PostgresDB) ListUnreferencedBlobs(ctx context.Context, minAge time.Duration, after string, scan, limit int) ([]string, string, error)
- func (p *PostgresDB) ListUserGroupMemberships(ctx context.Context) ([]*models.UserGroup, error)
- func (p *PostgresDB) ListUsers(ctx context.Context, page, perPage int) ([]*models.User, int, error)
- func (p *PostgresDB) ListUsersByGroup(ctx context.Context, groupID string) ([]*models.User, error)
- func (p *PostgresDB) ListVEXStatements(ctx context.Context, repoID, artifactID string) ([]*models.VEXStatement, error)
- func (p *PostgresDB) ListVulnScanOverview(ctx context.Context, params models.VulnScanListParams) (*models.VulnScanOverviewPage, error)
- func (p *PostgresDB) ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)
- func (p *PostgresDB) ListWebhookDeliveries(ctx context.Context, webhookID string, limit int) ([]*models.WebhookDelivery, error)
- func (p *PostgresDB) ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error)
- func (p *PostgresDB) ListWebhooksForEvent(ctx context.Context, repoID, eventType string) ([]*models.Webhook, error)
- func (p *PostgresDB) MarkGroupMetadataStale(ctx context.Context, groupID string) error
- func (p *PostgresDB) MarkPackumentStale(ctx context.Context, packageID string) error
- func (p *PostgresDB) MarkPresignedUploadCompleted(ctx context.Context, id, artifactID string) error
- func (p *PostgresDB) MarkRepoStale(ctx context.Context, repositoryID string) error
- func (p *PostgresDB) Migrate(ctx context.Context) error
- func (p *PostgresDB) MoveRepositoryToProject(ctx context.Context, repoID, toProjectID string, maxRepositories int) error
- func (p *PostgresDB) Ping(ctx context.Context) error
- func (p *PostgresDB) PoolStat() *pgxpool.Stat
- func (p *PostgresDB) PruneMavenMetadata(ctx context.Context, repositoryID, dir string, keep []string) ([]string, error)
- func (p *PostgresDB) PruneRepoDeltas(ctx context.Context, repoID string, maxCount int, maxBytes int64) ([]string, error)
- func (p *PostgresDB) PurgeAuditLogsBefore(ctx context.Context, cutoff time.Time, limit int) (int64, error)
- func (p *PostgresDB) PurgeExpiredBackupLeases(ctx context.Context) (int64, error)
- func (p *PostgresDB) PurgeTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashPurgeResult, error)
- func (p *PostgresDB) QuarantineArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error
- func (p *PostgresDB) QuarantineVulnArtifact(ctx context.Context, repoID, artifactID string, quarantined bool) error
- func (p *PostgresDB) ReconcileAllStorageUsage(ctx context.Context) (int64, error)
- func (p *PostgresDB) ReconcileStorageUsage(ctx context.Context, repoID string) (*models.StorageQuota, error)
- func (p *PostgresDB) RegenKeys(ctx context.Context, kind models.TrashKind, id string) (string, string, error)
- func (p *PostgresDB) ReleaseBlobReplication(ctx context.Context, sha256 string, version int64) error
- func (p *PostgresDB) ReleasePresignedUpload(ctx context.Context, id string) error
- func (p *PostgresDB) RelinkGomodZips(ctx context.Context, sha256 string, size int64, rowIDs []string) (int64, error)
- func (p *PostgresDB) RemoveBundleItem(ctx context.Context, bundleID, sha256 string) error
- func (p *PostgresDB) RemoveUserFromGroup(ctx context.Context, userID, groupID string) error
- func (p *PostgresDB) RepairBootstrapAdmin(ctx context.Context, username string) (bool, error)
- func (p *PostgresDB) ReplaceGroupMembers(ctx context.Context, groupRepoID string, memberIDs []string) error
- func (p *PostgresDB) RepoCatalogStats(ctx context.Context, repoIDs []string, withLastPublished bool) (map[string]models.RepoStats, error)
- func (p *PostgresDB) RepoSecuritySummary(ctx context.Context, repoID, packageName, version string) (*models.RepoSecuritySummary, error)
- func (p *PostgresDB) RequestReplicationVerify(ctx context.Context) (bool, error)
- func (p *PostgresDB) ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
- func (p *PostgresDB) ResolveAuditNames(ctx context.Context, refs models.AuditNameRefs) (*models.AuditNames, error)
- func (p *PostgresDB) ResolveGPGKeyForRepository(ctx context.Context, repoID string) (*models.GPGKey, error)
- func (p *PostgresDB) RestoreTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
- func (p *PostgresDB) RevokeProjectToken(ctx context.Context, projectID, tokenID string) (bool, error)
- func (p *PostgresDB) RevokeToken(ctx context.Context, tokenID string) error
- func (p *PostgresDB) RpmPackageExists(ctx context.Context, repoID, name, version, release string, epoch int, ...) (bool, error)
- func (p *PostgresDB) RubyGemsSpecsStamp(ctx context.Context, repoID string) (string, error)
- func (p *PostgresDB) SaveReplicationVerifyProgress(ctx context.Context, cursor string, run json.RawMessage) (bool, error)
- func (p *PostgresDB) ScanTierCandidates(ctx context.Context, after string, window int, clauses []models.TierScanClause) ([]models.BlobFacts, string, int, error)
- func (p *PostgresDB) SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time, ...) (bool, error)
- func (p *PostgresDB) SearchByProperty(ctx context.Context, repoID, key, value string) ([]string, error)
- func (p *PostgresDB) SearchCargoCrateSummaries(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrateSummary, int, error)
- func (p *PostgresDB) SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)
- func (p *PostgresDB) SearchComponents(ctx context.Context, repoID string, opts ComponentListOptions) ([]*models.Component, int, error)
- func (p *PostgresDB) SearchNuGetPackages(ctx context.Context, repoID, query string, skip, take int) ([]*models.NuGetPackage, int, error)
- func (p *PostgresDB) SearchRubyGems(ctx context.Context, repoID, query string) ([]*models.RubyGem, error)
- func (p *PostgresDB) SecurityFindingsSummary(ctx context.Context, f models.FindingFilter) (*models.FindingsSummary, error)
- func (p *PostgresDB) SecurityHealthStats(ctx context.Context) (*models.SecurityHealthStats, error)
- func (p *PostgresDB) SetArtifactProperties(ctx context.Context, repoID, artifactID string, props map[string]string, ...) error
- func (p *PostgresDB) SetBlobDeletionGrace(d time.Duration)
- func (p *PostgresDB) SetBlobReplicationLastError(ctx context.Context, message string) error
- func (p *PostgresDB) SetConanPackageDigests(ctx context.Context, id, md5, sha1 string) error
- func (p *PostgresDB) SetDebControlFields(ctx context.Context, packageID, maintainer, homepage string, ...) error
- func (p *PostgresDB) SetDockerManifestRefs(ctx context.Context, repoID string, m *models.DockerGCManifest, ...) error
- func (p *PostgresDB) SetGlobalGPGKey(ctx context.Context, id string) error
- func (p *PostgresDB) SetLicenseScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error
- func (p *PostgresDB) SetNuGetDependencyGroups(ctx context.Context, repoID, packageID, version string, groups []byte) error
- func (p *PostgresDB) SetPresignedUploadMultipartID(ctx context.Context, id, multipartID string) error
- func (p *PostgresDB) SetProjectGroup(ctx context.Context, projectID, groupID, role string, createdBy *string) error
- func (p *PostgresDB) SetProjectQuota(ctx context.Context, projectID string, maxSizeBytes, maxArtifactCount int64, ...) (*models.ProjectQuota, error)
- func (p *PostgresDB) SetRepositoryAttestationAttach(ctx context.Context, repoID string, enabled bool) error
- func (p *PostgresDB) SetRepositoryGPGKey(ctx context.Context, repoID, keyID, assignedBy string) error
- func (p *PostgresDB) SetSessionSSO(ctx context.Context, sessionID, providerSlug, encryptedIDToken string) error
- func (p *PostgresDB) SetSystemSetting(ctx context.Context, key, value string) error
- func (p *PostgresDB) SetTrashRetentionDays(days int)
- func (p *PostgresDB) SetVulnScanQuarantine(ctx context.Context, repoID, id string, quarantined bool) error
- func (p *PostgresDB) StartReplicationVerify(ctx context.Context, run json.RawMessage) (bool, error)
- func (p *PostgresDB) StorageBackendBusyReason(ctx context.Context, backendID string) (string, error)
- func (p *PostgresDB) StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
- func (p *PostgresDB) SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error
- func (p *PostgresDB) TouchBlobAccess(ctx context.Context, accessed map[string]time.Time, resolution time.Duration) (int64, error)
- func (p *PostgresDB) TouchDockerBlob(ctx context.Context, repoID, digest string) (bool, error)
- func (p *PostgresDB) TrashRepository(ctx context.Context, id, deletedBy string) (bool, error)
- func (p *PostgresDB) TrashRows(ctx context.Context, repoID string, kind models.TrashKind, ids []string, ...) (bool, error)
- func (p *PostgresDB) TrashedRepositoryByName(ctx context.Context, name string) (*models.TrashItem, error)
- func (p *PostgresDB) TryGomodRepairLock(ctx context.Context) (func(), bool, error)
- func (p *PostgresDB) UnreferencedBlobKeys(ctx context.Context, ids []string) ([]string, error)
- func (p *PostgresDB) UpdateBackupJob(ctx context.Context, job *models.BackupJob) error
- func (p *PostgresDB) UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
- func (p *PostgresDB) UpdateCleanupPolicyRunResult(ctx context.Context, id string, deletedCount int, runErr error) error
- func (p *PostgresDB) UpdateDockerUploadOffset(ctx context.Context, repositoryID, uploadUUID string, ...) (bool, error)
- func (p *PostgresDB) UpdateGroup(ctx context.Context, group *models.Group) error
- func (p *PostgresDB) UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
- func (p *PostgresDB) UpdateNPMPackageLatestVersion(ctx context.Context, packageID, latestVersion string) error
- func (p *PostgresDB) UpdateNPMVersionManifest(ctx context.Context, packageID, version string, manifest []byte) error
- func (p *PostgresDB) UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error
- func (p *PostgresDB) UpdateProject(ctx context.Context, project *models.Project) error
- func (p *PostgresDB) UpdatePromotionPipeline(ctx context.Context, pp *models.PromotionPipeline) error
- func (p *PostgresDB) UpdateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
- func (p *PostgresDB) UpdateRepository(ctx context.Context, repo *models.Repository) error
- func (p *PostgresDB) UpdateRepositoryAndMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
- func (p *PostgresDB) UpdateRpmPackageExtra(ctx context.Context, repoID, sha256 string, extra []byte) error
- func (p *PostgresDB) UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
- func (p *PostgresDB) UpdateSessionLastSeen(ctx context.Context, sessionID string, expiresAt time.Time) error
- func (p *PostgresDB) UpdateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
- func (p *PostgresDB) UpdateStorageBackendStatus(ctx context.Context, id, status string, message *string) error
- func (p *PostgresDB) UpdateStoragePolicy(ctx context.Context, pol *models.StoragePolicy) error
- func (p *PostgresDB) UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
- func (p *PostgresDB) UpdateStorageTier(ctx context.Context, t *models.StorageTier) error
- func (p *PostgresDB) UpdateTokenLastUsed(ctx context.Context, tokenID string) error
- func (p *PostgresDB) UpdateUser(ctx context.Context, user *models.User) error
- func (p *PostgresDB) UpdateUserLastLogin(ctx context.Context, id string, at time.Time) error
- func (p *PostgresDB) UpdateUserPassword(ctx context.Context, id, passwordHash string, mustChange bool) error
- func (p *PostgresDB) UpdateUserSSO(ctx context.Context, userID string, externalID, providerSlug string) error
- func (p *PostgresDB) UpdateUserSSOProfile(ctx context.Context, id string, email, fullName *string, lastLogin time.Time) error
- func (p *PostgresDB) UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
- func (p *PostgresDB) UpdateWebhook(ctx context.Context, wh *models.Webhook) error
- func (p *PostgresDB) UpdateWebhookDelivery(ctx context.Context, delivery *models.WebhookDelivery) error
- func (p *PostgresDB) UpsertAIAnalysis(ctx context.Context, analysis *models.AIAnalysis) error
- func (p *PostgresDB) UpsertBlob(ctx context.Context, sha256, blobKey string, sizeBytes int64) (string, error)
- func (p *PostgresDB) UpsertDeclarativeObjects(ctx context.Context, items []models.DeclarativeObject) ([]models.DeclarativeObject, error)
- func (p *PostgresDB) UpsertDependencyTrackPush(ctx context.Context, s *models.DependencyTrackPush) error
- func (p *PostgresDB) UpsertDockerTag(ctx context.Context, tag *models.DockerTag) error
- func (p *PostgresDB) UpsertNPMDistTag(ctx context.Context, t *models.NPMDistTag) (*models.NPMDistTag, error)
- func (p *PostgresDB) UpsertProxyCacheEntry(ctx context.Context, entry *models.ProxyCacheEntry) error
- func (p *PostgresDB) UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error
- func (p *PostgresDB) UpsertRepoMetadata(ctx context.Context, meta *models.RepoMetadata) error
- func (p *PostgresDB) UpsertRepositoryDependencyTrack(ctx context.Context, c *models.RepositoryDependencyTrack) error
- func (p *PostgresDB) UpsertVEXStatement(ctx context.Context, s *models.VEXStatement) error
- func (p *PostgresDB) VulnScanOverviewSummary(ctx context.Context, repoName string) (*models.VulnScanSummary, error)
- func (p *PostgresDB) WithBlobLock(ctx context.Context, sha256 string, fn func(ctx context.Context) error) error
- func (p *PostgresDB) WithBlobLocks(ctx context.Context, shas []string, fn func(ctx context.Context) error) error
- func (p *PostgresDB) YankCargoCrate(ctx context.Context, repoID, name, version string, yanked bool) error
- func (p *PostgresDB) YankRubyGem(ctx context.Context, repoID, name, version, platform string, yanked bool) error
- type PostgresTx
- func (t *PostgresTx) Commit() error
- func (t *PostgresTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (t *PostgresTx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (t *PostgresTx) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- func (t *PostgresTx) Rollback() error
- type ProjectRoleGuard
- type ProjectTokenSpec
- type SnapshotReader
- type Transaction
- type TrashStore
Constants ¶
const ( // BlobReplicationCopy makes the blob exist on the replica. BlobReplicationCopy = "copy" // BlobReplicationDelete makes the blob disappear from the replica. BlobReplicationDelete = "delete" )
Operations of the blob replication queue (see BlobReplicationStore).
const ( // BlobDeletionScopeAll deletes every copy of the blob, on every tier: the // blob itself was deleted. BlobDeletionScopeAll = "*" // BlobDeletionScopePrimary deletes the copy on the primary (default) store. BlobDeletionScopePrimary = "" )
Scopes of a queued blob deletion (BlobDeletion.Scope). Any other value is the storage_backends id of the tier whose copy a placement flip retired.
Variables ¶
var ( ErrSBOMReportNotFound = errors.New("SBOM report not found") ErrLicensePolicyNotFound = errors.New("license policy not found") )
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") )
var ( // ErrGPGKeyNotFound is returned when a GPG key does not exist. ErrGPGKeyNotFound = errors.New("GPG key not found") // ErrGPGKeyExists is returned when a key with the same name or fingerprint is already stored. ErrGPGKeyExists = errors.New("GPG key already exists") )
var ( // ErrProjectTokenLimit: the project already has the maximum of active tokens. ErrProjectTokenLimit = errors.New("project token limit reached") // ErrProjectTokenName: an active token of the project already has the name. ErrProjectTokenName = errors.New("project token name already in use") )
Errors of project token creation.
var ( // ErrProjectNotFound: the project does not exist (any more). ErrProjectNotFound = errors.New("project not found") // ErrProjectOwnerLocked: the project's recorded owner can be neither // demoted nor removed. ErrProjectOwnerLocked = errors.New("the project owner cannot be demoted or removed") // ErrLastProjectOwner: the change would leave the project without an owner. ErrLastProjectOwner = errors.New("cannot remove or demote the last owner") )
Errors of the locked project member/group changes.
var ( // ErrTrashNotFound means no trashed row matches the kind/id (it was never // deleted, was already restored, or was purged). ErrTrashNotFound = errors.New("trash item not found") // ErrAmbiguousPyPIFilename means several packages of one repository hold a // file with the same name. ErrAmbiguousPyPIFilename = errors.New("pypi filename is ambiguous") // ErrTrashConflict means a restore collided with a live row that took over // the item's unique key while it sat in the trash. ErrTrashConflict = errors.New("a live item with the same identity already exists") // ErrTrashRepoTrashed means the item's repository is itself in the trash. ErrTrashRepoTrashed = errors.New("the item's repository is in the trash") // ErrTrashManifestInTrash means a docker tag cannot be restored because the // manifest it points at is itself in the trash (restore the manifest, which // brings its tags back). ErrTrashManifestInTrash = errors.New("the tag's manifest is in the trash") // ErrTrashUnknownKind means the kind is not a registered trash kind. ErrTrashUnknownKind = errors.New("unknown trash kind") )
var ErrChecksumDrift = errors.New("checksum drift")
var ErrDockerBlobsMissing = errors.New("manifest references a blob that is not available to the image")
ErrDockerBlobsMissing is returned by CreateDockerManifest when a blob the manifest requires is not (or no longer) available to its image.
var ErrDockerRowNotFound = errors.New("docker row not found")
ErrDockerRowNotFound is returned by DeleteDockerBlob and DeleteDockerManifest when no row matched: a concurrent request removed it first. Callers release the row's storage quota only when the delete removed it.
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.
var ErrInvalidAuditLimit = errors.New("audit page limit must be positive")
ErrInvalidAuditLimit is returned by ListAuditLogs for a page size below 1.
var ErrInvalidBlobSHA256 = errors.New("invalid blob sha256: must be 64 lowercase hex characters")
ErrInvalidBlobSHA256 is returned when a blob row would be keyed by anything other than a lowercase 64-character hex SHA-256. blobs.sha256 is UNIQUE and every upsert resolves conflicts on it, so a single malformed value (the empty string in particular) would make unrelated artifacts share one row and serve each other's bytes.
var ErrInvalidConnOption = errors.New("invalid database option key")
ErrInvalidConnOption is returned when a database option key is not a valid PostgreSQL runtime parameter name.
var ErrInvalidFindingFilter = errors.New("invalid security finding filter")
ErrInvalidFindingFilter is returned by ListSecurityFindings for a type, severity or status it does not know, and for a page size below 1.
var ErrInvalidVulnScanFilter = errors.New("invalid vulnerability scan filter")
ErrInvalidVulnScanFilter is returned by ListVulnScanOverview for a severity, status or scanner it does not know, and for a page size below 1.
var ErrLastAdmin = errors.New("cannot delete the last enabled admin")
ErrLastAdmin is returned when deleting the last enabled admin user.
var ErrLicenseScanNotFound = errors.New("license scan result not found")
ErrLicenseScanNotFound is returned when a license scan result does not exist in the repository.
var ErrPresignedUploadCap = errors.New("too many pending presigned uploads")
ErrPresignedUploadCap is returned by CreatePresignedUploadCapped when the user already has the maximum number of outstanding uploads.
var ErrProjectQuotaExceeded = errors.New("project storage quota would be exceeded")
ErrProjectQuotaExceeded is returned when moving a repository would push the target project past its storage ceiling.
var ErrProjectRepoLimit = errors.New("project repository limit reached")
ErrProjectRepoLimit is returned when creating or moving a repository would exceed the project's max_repositories.
var ErrRepositoryNotFound = errors.New("repository not found")
ErrRepositoryNotFound is returned when a repository to modify does not exist (or is trashed).
var ErrVEXStatementNotFound = errors.New("VEX statement not found")
ErrVEXStatementNotFound is returned when a VEX statement does not exist in the repository.
Functions ¶
func FlaggedArtifactPredicate ¶ added in v0.11.0
FlaggedArtifactPredicate is the SQL predicate "the package row idExpr of the repository repoExpr is flagged". Both are SQL expressions of the caller's query (idExpr is the row's uuid; artifact_refs.artifact_path holds it as text). It probes artifact_refs by its (repository_id, artifact_path) unique index once per row it is evaluated for, so apply it after the cheaper predicates.
func IsForeignKeyViolation ¶ added in v0.2.0
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
IsUniqueViolation reports whether err is a PostgreSQL unique_violation.
func IsValidBlobSHA256 ¶ added in v0.5.0
IsValidBlobSHA256 reports whether s is a well-formed blobs.sha256 value. It mirrors storage.ValidateBlobID, which this package cannot import (storage depends on database).
func TrashRowsInTx ¶ added in v0.8.0
func TrashRowsInTx(ctx context.Context, tx interface { ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) }, repoID string, kind models.TrashKind, ids []string, deletedBy string, ) error
TrashRowsInTx soft-deletes rows of repoID inside the caller's transaction, whatever the repository's retention: a purge removes them for good once the retention window has passed. A caller that replaces live content (a forced bundle promotion) uses it so the replaced rows stay restorable. ErrTrashNotFound means none of the rows is live in repoID.
func UniqueViolationConstraint ¶ added in v0.2.0
UniqueViolationConstraint returns the violated constraint/index name when err is a unique_violation, and "" otherwise.
Types ¶
type AuditRetentionStore ¶ added in v0.10.0
type AuditRetentionStore interface {
// PurgeAuditLogsBefore deletes up to limit audit entries created before
// cutoff, oldest first, and returns how many it removed. A result below
// limit means nothing older than cutoff is left.
PurgeAuditLogsBefore(ctx context.Context, cutoff time.Time, limit int) (int64, error)
}
AuditRetentionStore deletes audit entries past their retention window. It is implemented by *PostgresDB and found by the retention worker with a type assertion on Database.
type BlobDeletion ¶ added in v0.7.0
type BlobDeletion struct {
SHA256 string
Scope string
QueuedAt time.Time
NotBefore time.Time
Attempts int
}
BlobDeletion is a queued deletion of blob bytes (see EnqueueBlobDeletion).
type BlobDeletionStore ¶ added in v0.7.0
type BlobDeletionStore interface {
// ClaimBlobDeletions hands out up to limit deletions that are due: past
// their grace period and not needed by any running backup. A claimed row is
// invisible to other callers for claimFor.
ClaimBlobDeletions(ctx context.Context, limit int, claimFor time.Duration) ([]BlobDeletion, error)
// BlobDeletionDue re-checks, under the per-blob lock, that the deletion is
// still due.
BlobDeletionDue(ctx context.Context, sha256, scope string) (bool, error)
// DeleteBlobDeletion removes a queued deletion.
DeleteBlobDeletion(ctx context.Context, sha256, scope string) error
// CountBlobDeletions returns the queue length.
CountBlobDeletions(ctx context.Context) (int64, error)
// PurgeExpiredBackupLeases removes leases of backups that stopped renewing.
PurgeExpiredBackupLeases(ctx context.Context) (int64, error)
}
BlobDeletionStore is the deferred-deletion queue the blob deletion sweeper works through; *PostgresDB implements it. See docs/operations/storage.md.
type BlobReplication ¶ added in v0.9.0
type BlobReplication struct {
SHA256 string
// Op is BlobReplicationCopy or BlobReplicationDelete.
Op string
// Version changes whenever Op changes; CompleteBlobReplication and
// FailBlobReplication act only on the version that was claimed.
Version int64
Attempts int
EnqueuedAt time.Time
// NextAttemptAt, LastError are set by GetBlobReplication only.
NextAttemptAt time.Time
LastError string
}
BlobReplication is a queued replication operation.
type BlobReplicationBacklog ¶ added in v0.9.0
type BlobReplicationBacklog struct {
Copy int64
Delete int64
// Failing is the number of operations with at least the attempts asked for.
Failing int64
// OldestAgeSeconds is the age of the oldest queued operation (0 when empty).
OldestAgeSeconds float64
}
BlobReplicationBacklog summarizes the queue.
type BlobReplicationState ¶ added in v0.9.0
type BlobReplicationState struct {
ReplicatedTotal int64
ReplicatedBytes int64
LastError string
LastErrorAt *time.Time
// VerifyRequested is set by an admin asking for a verify pass; the next
// worker tick starts it.
VerifyRequested bool
// VerifyCursor is the last blob id the running verify pass finished.
VerifyCursor string
// VerifyRun is the JSON counters of the running pass (nil = none runs);
// LastVerify those of the last finished one.
VerifyRun json.RawMessage
LastVerify json.RawMessage
}
BlobReplicationState is the shared singleton state of the replication subsystem: totals, the last error and the verify job's progress.
type BlobReplicationStore ¶ added in v0.9.0
type BlobReplicationStore interface {
// EnqueueBlobReplication queues op ("copy" or "delete") for the blob. The
// latest operation wins: a different op replaces the queued one (new
// version, due at once), the same op again is a no-op.
EnqueueBlobReplication(ctx context.Context, sha256, op string) error
// ClaimBlobReplications hands out up to limit operations due at asOf. A
// claimed row is invisible to other callers until asOf+claimFor.
ClaimBlobReplications(ctx context.Context, asOf time.Time, limit int, claimFor time.Duration) ([]BlobReplication, error)
// CompleteBlobReplication removes the claimed operation; false when it was
// superseded meanwhile (a newer version stays queued).
CompleteBlobReplication(ctx context.Context, sha256 string, version int64) (bool, error)
// FailBlobReplication records a failed attempt: attempts+1, the error and
// the next attempt time; false when the operation was superseded.
FailBlobReplication(ctx context.Context, sha256 string, version int64, lastError string, nextAttempt time.Time) (bool, error)
// ReleaseBlobReplication gives a claimed operation back unprocessed.
ReleaseBlobReplication(ctx context.Context, sha256 string, version int64) error
// GetBlobReplication returns the queued operation of the blob, nil when none.
GetBlobReplication(ctx context.Context, sha256 string) (*BlobReplication, error)
// BlobReplicationBacklog counts the queue; failingAttempts is the attempt
// count from which an operation counts as failing.
BlobReplicationBacklog(ctx context.Context, failingAttempts int) (BlobReplicationBacklog, error)
// ListBlobSHAs returns up to limit blobs-table ids greater than after, ascending.
ListBlobSHAs(ctx context.Context, after string, limit int) ([]string, error)
// BlobReplicationReferenced reports whether the database still needs the
// blob: a blobs row, generated repository metadata or a package row.
BlobReplicationReferenced(ctx context.Context, sha256 string) (bool, error)
// GetBlobReplicationState reads the singleton state.
GetBlobReplicationState(ctx context.Context) (BlobReplicationState, error)
// AddBlobReplicationProgress adds finished copies and their bytes.
AddBlobReplicationProgress(ctx context.Context, copies, bytes int64) error
// SetBlobReplicationLastError records the most recent failure.
SetBlobReplicationLastError(ctx context.Context, message string) error
// RequestReplicationVerify asks for a verify pass; false when one is
// running or already requested.
RequestReplicationVerify(ctx context.Context) (bool, error)
// StartReplicationVerify begins a pass with the initial counters; false
// when another replica already runs one.
StartReplicationVerify(ctx context.Context, run json.RawMessage) (bool, error)
// SaveReplicationVerifyProgress stores the cursor and counters of the
// running pass; false when no pass runs.
SaveReplicationVerifyProgress(ctx context.Context, cursor string, run json.RawMessage) (bool, error)
// FinishReplicationVerify stores the result of the pass and ends it.
FinishReplicationVerify(ctx context.Context, result json.RawMessage) error
}
BlobReplicationStore is the durable queue and state behind async blob replication (docs/operations/replication.md); *PostgresDB implements it.
type BootstrapAdmin ¶ added in v0.11.0
type BootstrapAdmin struct {
Username string
PasswordHash string
// MustChangePassword forces a password change at first login.
MustChangePassword bool
// PasswordExpiresAt, when set, is the instant after which the password is
// rejected at login.
PasswordExpiresAt *time.Time
// TokenHash is the lookup digest of an access token to create for the
// admin; empty creates none.
TokenHash string
TokenName string
TokenExpiresAt *time.Time
}
BootstrapAdmin describes the first admin account created on an empty instance.
type ComponentListOptions ¶ added in v0.6.0
type ComponentListOptions struct {
// Format restricts the listing to one package format ("" = all).
Format string
// Name restricts it to rows whose listed name equals Name exactly.
Name string
// Query keeps rows whose listed name or version contains Query, ignoring case.
Query string
// SortByName orders by (name, version) instead of newest first.
SortByName bool
Page int
Limit int
}
ComponentListOptions selects and orders a repository's package listing.
type ComponentSearcher ¶ added in v0.6.0
type ComponentSearcher interface {
SearchComponents(ctx context.Context, repoID string, opts ComponentListOptions) ([]*models.Component, int, error)
}
ComponentSearcher is implemented by stores that can filter and order a repository's package listing (GET /api/v1/repositories/{name}/packages with package_name, q or sort). Kept separate from the main interface so only the real store has to provide it. It returns the requested page and the total number of matching rows.
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
// UpdateRepositoryAndMembers is UpdateRepository plus ReplaceGroupMembers in
// one transaction.
UpdateRepositoryAndMembers(ctx context.Context, repo *models.Repository, memberIDs []string) 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
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)
// GetRepoComponentDetail resolves a package-listing row id (any format) to
// the row with its stored metadata, scoped to repoID. Returns nil, nil when
// the id is not in that repository.
GetRepoComponentDetail(ctx context.Context, repoID, id string) (*models.ComponentDetail, error)
// RepoCatalogStats returns the stored size, quota and security aggregates of
// the repositories, one entry per id, and the newest-package time when
// withLastPublished.
RepoCatalogStats(ctx context.Context, repoIDs []string, withLastPublished bool) (map[string]models.RepoStats, error)
// CountRepoPackageNames returns the number of distinct package names of
// each repository, one entry per id.
CountRepoPackageNames(ctx context.Context, repoIDs []string) (map[string]int64, error)
// ListRepoPackageRollup lists a repository's packages, one row per package
// (latest version, version count, latest size), with the total.
ListRepoPackageRollup(ctx context.Context, opts models.PackageRollupOptions) ([]models.PackageRollup, int, error)
// ArtifactSecurity returns the scan state of the listed package rows of a
// repository by row id; rows never scanned have no entry.
ArtifactSecurity(ctx context.Context, repoID string, artifactIDs []string) (map[string]models.ArtifactSecurity, error)
// ListRecentPackages returns the newest package versions across repoIDs,
// newest first, at most limit.
ListRecentPackages(ctx context.Context, repoIDs []string, limit int) ([]models.RecentPackage, error)
GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)
// GetComponentBySHA256 returns the live rpm or deb package in a repository whose blob has the given sha256, or nil.
GetComponentBySHA256(ctx context.Context, repoID, sha256 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
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)
// 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)
ListMavenGARefs(ctx context.Context, repoID, groupID, artifactID string) (*models.MavenGARefs, error)
GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)
// GetLatestSnapshotFile returns the newest snapshot build of the file with
// the given classifier and extension.
GetLatestSnapshotFile(ctx context.Context, repoID, groupID, artifactID, version, classifier, extension 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)
// GetNPMVersionStates returns number and deprecation of every live version
// of the package, without the manifests.
GetNPMVersionStates(ctx context.Context, packageID string) ([]models.NPMVersionState, error)
// UpdateNPMVersionManifest replaces the stored manifest of a live version
// (used for `npm deprecate`).
UpdateNPMVersionManifest(ctx context.Context, packageID, version string, manifest []byte) 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 is a compare-and-set: it moves the offset from
// oldOffset to newOffset and reports false when it no longer equals oldOffset.
UpdateDockerUploadOffset(ctx context.Context, repositoryID, uploadUUID string, oldOffset, newOffset int64) (bool, 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
ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
// ListGroupMemberRepositories returns the live member repositories of a
// group in priority order (the order of ListGroupMembers) in one query.
ListGroupMemberRepositories(ctx context.Context, groupRepoID string) ([]*models.Repository, error)
// ListGroupsOfMember returns the live group repositories the repository is
// a member of, oldest link first.
ListGroupsOfMember(ctx context.Context, memberRepoID string) ([]*models.Repository, error)
// Deb/rpm group metadata (docs/repositories/hosted-proxy-group.md).
// MarkGroupMetadataStale flags a group's merged metadata for regeneration.
MarkGroupMetadataStale(ctx context.Context, groupID string) error
// GetGroupMetadataState returns a group's regeneration state, nil when it has none.
GetGroupMetadataState(ctx context.Context, groupID string) (*models.GroupMetadataState, error)
// ListMetadataGroupsOfMember returns the deb/rpm groups that list the repository as a member.
ListMetadataGroupsOfMember(ctx context.Context, memberRepoID string) ([]string, error)
// ListStaleMetadataGroups returns the deb/rpm groups that are stale or were never generated.
ListStaleMetadataGroups(ctx context.Context) ([]string, error)
// GetGroupPackageOwner returns the member owning a file the group's merged index lists.
GetGroupPackageOwner(ctx context.Context, groupID, path string) (string, bool, 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
// CreateProjectRepository is CreateRepositoryWithMembers under the project's
// max_repositories cap (ErrProjectRepoLimit), checked with the project row locked.
CreateProjectRepository(ctx context.Context, repo *models.Repository, memberIDs []string, maxRepositories int) error
// MoveRepositoryToProject reassigns a live repository to another project
// under the target's cap when maxRepositories > 0 (ErrProjectRepoLimit).
MoveRepositoryToProject(ctx context.Context, repoID, toProjectID string, maxRepositories int) 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)
// HelmIndexStamp is a cheap validator of a repository's index.yaml: it
// changes exactly when a live chart is added or removed.
HelmIndexStamp(ctx context.Context, repoID string) (string, error)
// PyPI methods
CreatePyPIPackage(ctx context.Context, pkg *models.PyPIPackage) error
// GetPyPIPackageByFilename returns the live file with this filename, nil
// when there is none and ErrAmbiguousPyPIFilename when several packages of
// the repository hold a file of that name.
GetPyPIPackageByFilename(ctx context.Context, repoID, filename string) (*models.PyPIPackage, error)
DeletePyPIPackage(ctx context.Context, repoID, name, version, filename string) error
ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)
// ListPyPIPackageNames returns the distinct stored project names of a
// repository, sorted, without loading any file row.
ListPyPIPackageNames(ctx context.Context, repoID string) ([]string, 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
// SetNuGetDependencyGroups records the dependency groups JSON of a package
// that has none stored yet (published before they were persisted).
SetNuGetDependencyGroups(ctx context.Context, repoID, packageID, version string, groups []byte) error
ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)
ListNuGetPackageVersions(ctx context.Context, repoID, packageID string) ([]*models.NuGetPackage, error)
// SearchNuGetPackages pages over matching packages: skip/take count
// packages, the total is the number of matching packages, and every live
// version of each package on the page is returned.
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
// UpdateUserLastLogin sets only last_login_at, so a login finishing from a
// stale snapshot cannot undo a concurrent disable or password reset.
UpdateUserLastLogin(ctx context.Context, id string, at time.Time) error
// UpdateUserSSOProfile sets only email (when non-nil), full_name (when
// non-nil) and last_login_at, so an SSO login finishing from a stale
// snapshot cannot undo a concurrent disable or password reset.
UpdateUserSSOProfile(ctx context.Context, id string, email, fullName *string, lastLogin time.Time) error
// UpdateUserPassword sets only password_hash and must_change_password.
UpdateUserPassword(ctx context.Context, id, passwordHash string, mustChange bool) 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, binds it to the admin-all permission target and, when the spec
// carries a token hash, creates its access token. It reports false without
// creating anything when another replica already created a user.
CreateBootstrapAdmin(ctx context.Context, spec BootstrapAdmin) (bool, error)
// GetPasswordExpiry returns when the user's password stops being accepted
// at login, or nil when it does not expire (or the user has none). It is
// only meaningful while the account is flagged must_change_password.
GetPasswordExpiry(ctx context.Context, userID string) (*time.Time, 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
// SetSessionSSO records the SSO provider (and its encrypted ID token) a
// session was created by, for RP-initiated logout.
SetSessionSSO(ctx context.Context, sessionID, providerSlug, encryptedIDToken string) error
// GetSessionSSO returns the SSO record of the session with tokenHash, or
// nil when the session was not created by SSO (or does not exist).
GetSessionSSO(ctx context.Context, tokenHash string) (*models.SessionSSO, 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
// DeleteUser hard-deletes a human user with its sessions, tokens, memberships
// and SSO link. false means not found; ErrLastAdmin refuses the last enabled admin.
DeleteUser(ctx context.Context, id string) (bool, 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)
// ListPermissionAssignments returns every permission assignment (backup export).
ListPermissionAssignments(ctx context.Context) ([]*models.PermissionAssignment, error)
// ListUserGroupMemberships returns every user-to-group membership (backup export).
ListUserGroupMemberships(ctx context.Context) ([]*models.UserGroup, 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
// ListPermissionAssignmentsForTarget returns the assignments of one target
// with principal names, ordered by type then name.
ListPermissionAssignmentsForTarget(ctx context.Context, targetID string) ([]models.PermissionAssignmentView, error)
// Declarative (oa apply) ownership markers.
ListDeclarativeObjects(ctx context.Context) ([]models.DeclarativeObject, error)
// UpsertDeclarativeObjects stores the markers by (kind, name) in one
// transaction and returns them as stored.
UpsertDeclarativeObjects(ctx context.Context, items []models.DeclarativeObject) ([]models.DeclarativeObject, error)
// DeleteDeclarativeObject removes one marker and reports whether it existed.
DeleteDeclarativeObject(ctx context.Context, kind, name string) (bool, error)
CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
GetSSOProviderBySlug(ctx context.Context, slug 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)
// 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)
// BeginBackupSnapshot freezes the database at one instant for a backup and
// registers a lease that keeps the blob bytes that instant references from
// being deleted until Release. The lease is renewed in the background and
// expires leaseTTL after the last renewal, so a crashed backup does not
// hold deletions back forever. See SnapshotReader.
BeginBackupSnapshot(ctx context.Context, leaseTTL time.Duration) (SnapshotReader, error)
// Go Module Proxy methods
CreateGoModule(ctx context.Context, mod *models.GoModule) error
GetGoModule(ctx context.Context, repoID, modulePath, version string) (*models.GoModule, error)
ListGoModuleVersions(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)
// ListUnifiedTokens pages the personal, project and federation tokens the
// caller may see (params.Admin: all), newest first, with the matching total.
ListUnifiedTokens(ctx context.Context, params models.TokenListParams) ([]*models.TokenListItem, int, error)
// ResolveAuditNames looks up the display names of the entities one audit
// page refers to with a single query; entities that were deleted are absent.
ResolveAuditNames(ctx context.Context, refs models.AuditNameRefs) (*models.AuditNames, 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)
// ListProjectCleanupPolicies lists a project's default policies (RepositoryID "").
ListProjectCleanupPolicies(ctx context.Context, projectID string) ([]*models.CleanupPolicy, error)
// ListProjectCleanupRepositories lists the live hosted repositories a project
// default policy applies to: those without an enabled repository-level policy.
ListProjectCleanupRepositories(ctx context.Context, projectID string) ([]string, 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)
ListCargoCrateVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)
// CargoIndexStamp is a cheap validator of one crate's sparse index entry:
// it changes when a live version is added, removed or (un)yanked.
CargoIndexStamp(ctx context.Context, repoID, name string) (string, error)
// ListCargoIndexVersions returns the live versions of a crate with only the
// columns the sparse index needs (Name, Version, MetadataJSON, Checksum,
// Yanked), oldest first.
ListCargoIndexVersions(ctx context.Context, repoID, name string) ([]*models.CargoCrate, error)
SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)
// SearchCargoCrateSummaries matches crates by name or description and
// returns one summary per crate (at most limit, by name) together with the
// total number of matching crates.
SearchCargoCrateSummaries(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrateSummary, int, 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)
ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)
// RubyGemsSpecsStamp is a cheap validator of every specs index of a
// repository: it changes when a listed gem is added, removed or yanked.
RubyGemsSpecsStamp(ctx context.Context, repoID string) (string, error)
// ListRubyGemSpecs returns the listed (not yanked) gems with only Name,
// Version and Platform set, by name then version descending.
ListRubyGemSpecs(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, platform 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)
// Presigned uploads (staging rows awaiting their complete call).
// CreatePresignedUpload fills ID and CreatedAt. GetPresignedUpload returns
// nil, nil when the id is unknown or belongs to another repository.
CreatePresignedUpload(ctx context.Context, u *models.PresignedUpload) error
GetPresignedUpload(ctx context.Context, repoID, id string) (*models.PresignedUpload, error)
DeletePresignedUpload(ctx context.Context, id string) error
// ClaimPresignedUpload takes the complete lease of an upload for up to
// lease. It reports false when the upload is already completed or another
// complete holds an unexpired lease.
ClaimPresignedUpload(ctx context.Context, repoID, id string, lease time.Duration) (bool, error)
// ReleasePresignedUpload gives up the lease of an upload that was not completed.
ReleasePresignedUpload(ctx context.Context, id string) error
// MarkPresignedUploadCompleted records that the upload produced artifactID.
MarkPresignedUploadCompleted(ctx context.Context, id, artifactID string) error
// CreatePresignedUploadCapped is CreatePresignedUpload that fails with
// ErrPresignedUploadCap when u.CreatedBy already has maxPending uploads
// that are neither completed nor expired (maxPending <= 0: no cap). The
// count and the insert are serialized per user, so parallel creates cannot
// overshoot the cap.
CreatePresignedUploadCapped(ctx context.Context, u *models.PresignedUpload, maxPending int) error
// ExistingPresignedUploadIDs returns the subset of ids that have a row.
ExistingPresignedUploadIDs(ctx context.Context, ids []string) ([]string, error)
// SetPresignedUploadMultipartID records the backend handle of the upload's
// open multipart upload.
SetPresignedUploadMultipartID(ctx context.Context, id, multipartID string) error
// ExtendPresignedUploadExpiry moves the complete deadline of a pending
// upload forward to expiresAt (it never shortens it), so an upload that is
// still receiving parts does not expire under the client.
ExtendPresignedUploadExpiry(ctx context.Context, id string, expiresAt time.Time) error
ListExpiredPresignedUploads(ctx context.Context, limit int) ([]string, error)
// SBOM methods
CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error
ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)
// License compliance methods
CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
GetLicenseScanResult(ctx context.Context, repoID, artifactID string) (*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)
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
// GetProjectQuota returns the project's storage ceiling (unlimited when never set).
GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
// SetProjectQuota stores the ceiling (0 = unlimited) and initialises the
// counters from the repository counters when a limit is first enabled.
SetProjectQuota(ctx context.Context, projectID string, maxSizeBytes, maxArtifactCount int64, warnThresholdPercent int) (*models.ProjectQuota, error)
// GetProjectUsage sums the repository counters of a project and lists them per repository.
GetProjectUsage(ctx context.Context, projectID string) (*models.ProjectUsage, error)
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
// ListQuotaOverview pages every live repository and project with its limits
// and live usage, largest usage first, with the matching total.
ListQuotaOverview(ctx context.Context, params models.QuotaListParams) ([]*models.QuotaOverview, int, error)
// GetRepositoryUsage counts the packages and versions a repository holds
// and when the newest was created (scans that repository's rows).
GetRepositoryUsage(ctx context.Context, repoID string) (*models.RepositoryUsage, error)
// ListStorageQuotas returns the limits of every repository quota row (backup export).
ListStorageQuotas(ctx context.Context) ([]*models.StorageQuota, 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.
// A non-zero reservation leaves a pending entry (quota_pending) until the
// package row insert or the matching DecrementStorageUsage consumes it, so
// a reconcile during the upload stays exact.
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
// ChargeStorageUsage adds usage for a package row that already exists,
// past any limit, leaving no pending entry (see ReserveStorageUsage).
ChargeStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) 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)
// StorageBackendBusyReason says why a backend must not change kind/config ("" = idle).
StorageBackendBusyReason(ctx context.Context, backendID string) (string, error)
// StorageTierUsage returns blob counts and bytes per placement ("" = primary store).
StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
UpdateStorageBackendStatus(ctx context.Context, id, status string, message *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)
// Project methods
CreateProject(ctx context.Context, project *models.Project) error
GetProject(ctx context.Context, id string) (*models.Project, error)
GetProjectByName(ctx context.Context, name string) (*models.Project, error)
UpdateProject(ctx context.Context, project *models.Project) error
DeleteProject(ctx context.Context, id string) error
// ListProjects returns the projects the user belongs to (recorded owner,
// member, or through a group).
ListProjects(ctx context.Context, userID string) ([]*models.Project, error)
ListAllProjects(ctx context.Context) ([]*models.Project, error)
AddProjectMember(ctx context.Context, projectID, userID, role string) error
ListProjectMembers(ctx context.Context, projectID string) ([]*models.ProjectMember, error)
GetProjectMember(ctx context.Context, projectID, userID string) (*models.ProjectMember, error)
// ChangeProjectMember sets, adds or removes (newRole "") a member's role
// under the project row lock; guard vetoes the change (see ProjectRoleGuard).
ChangeProjectMember(ctx context.Context, projectID, userID, newRole string, guard ProjectRoleGuard) error
// ChangeProjectGroup attaches, changes or detaches (newRole "") a group the same way.
ChangeProjectGroup(ctx context.Context, projectID, groupID, newRole string, createdBy *string, guard ProjectRoleGuard) error
// ListProjectRepositories returns one page of the project's live repositories and their total.
ListProjectRepositories(ctx context.Context, projectID string, page, limit int) ([]*models.Repository, int, error)
// ListProjectStats returns the member count, usage and size ceiling of the
// given projects with grouped queries (one round trip for the whole page).
ListProjectStats(ctx context.Context, projectIDs []string) (map[string]*models.ProjectStats, error)
// CountRepositoriesByProject returns the live repository count per project ID.
CountRepositoriesByProject(ctx context.Context, projectIDs []string) (map[string]int, error)
// CreateProjectToken mints a project token: service user, membership and
// deploy token in one transaction (ErrProjectTokenLimit, ErrProjectTokenName).
CreateProjectToken(ctx context.Context, spec ProjectTokenSpec) (*models.Token, error)
// ListProjectTokens returns the project's active tokens; createdBy limits them to one creator.
ListProjectTokens(ctx context.Context, projectID string, createdBy *string) ([]*models.Token, error)
// RevokeProjectToken revokes a token of the project and disables its service user; false when there is none.
RevokeProjectToken(ctx context.Context, projectID, tokenID string) (bool, error)
ListProjectGroups(ctx context.Context, projectID string) ([]*models.ProjectGroup, error)
GetProjectGroup(ctx context.Context, projectID, groupID string) (*models.ProjectGroup, error)
// SetProjectGroup attaches a group with role, or changes an existing role,
// without any guard (backup restore); API changes use ChangeProjectGroup.
SetProjectGroup(ctx context.Context, projectID, groupID, role string, createdBy *string) error
// ListProjectGrantsByUser returns every project role the user holds:
// recorded owner, membership rows and group attachments, one grant per
// source (cached like the other per-request auth lookups).
ListProjectGrantsByUser(ctx context.Context, userID string) ([]*models.ProjectGrant, 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
// GetCondaPackageFile returns the live package file with exactly this
// name, version, build, platform and extension (".tar.bz2" or ".conda").
GetCondaPackageFile(ctx context.Context, repoID, name, version, buildString, platform, extension string) (*models.CondaPackage, error)
DeleteCondaPackage(ctx context.Context, id string) error
ListCondaPackages(ctx context.Context, repoID, platform string) ([]*models.CondaPackage, error)
// CondaRepodataStamp is a cheap validator of one platform's repodata.json:
// it changes exactly when a live package is added or removed.
CondaRepodataStamp(ctx context.Context, repoID, platform string) (string, 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. A conan_packages row is one stored file of a recipe or
// package revision.
//
// CreateConanPackage stores the file, replacing the blob of the live row with
// the same key. GetConanPackage returns (nil, nil) when there is none.
CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error
GetConanPackage(ctx context.Context, repoID string, key models.ConanFileKey) (*models.ConanPackage, error)
// ListConanRecipeFiles returns every live file of one recipe: all its recipe
// and package revisions.
ListConanRecipeFiles(ctx context.Context, repoID, name, version, userChannel string) ([]*models.ConanPackage, error)
// ListConanRecipes returns the distinct recipes of a repository.
ListConanRecipes(ctx context.Context, repoID string) ([]models.ConanRecipe, error)
// FindConanPackageBySHA1 returns a live file of the repository with this
// SHA-1 (Conan checksum deploy), or (nil, nil).
FindConanPackageBySHA1(ctx context.Context, repoID, sha1 string) (*models.ConanPackage, error)
// SetConanPackageDigests records the digests of a file stored without them;
// it leaves updated_at (the revision time) alone.
SetConanPackageDigests(ctx context.Context, id, md5, sha1 string) 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 deletes an item of a draft bundle (ErrBundleNotDraft otherwise).
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
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.
// A non-nil sig is stored with the bundle and requires the item set to still match sig.ItemIDs.
SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time, sig *models.BundleSignature) (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
// ListVulnScanOverview returns one keyset page of vulnerability scans across all
// repositories, worst first, without their findings (ErrInvalidVulnScanFilter
// for an unknown severity, status or scanner or a page size below 1).
ListVulnScanOverview(ctx context.Context, params models.VulnScanListParams) (*models.VulnScanOverviewPage, error)
// VulnScanOverviewSummary counts the overview's scans, optionally of one repository (by name).
VulnScanOverviewSummary(ctx context.Context, repoName string) (*models.VulnScanSummary, error)
// ListSecurityFindings returns one keyset page of the vuln, license, secret and AI findings
// within a scope, worst first (ErrInvalidFindingFilter for an unknown type, severity or status
// or a page size below 1).
ListSecurityFindings(ctx context.Context, params models.FindingListParams) (*models.FindingPage, error)
// SecurityFindingsSummary counts findings per type and the scanned repositories of a scope.
SecurityFindingsSummary(ctx context.Context, filter models.FindingFilter) (*models.FindingsSummary, error)
// SecurityHealthStats returns the instance-wide scan queue and coverage numbers.
SecurityHealthStats(ctx context.Context) (*models.SecurityHealthStats, error)
// LatestFinishedDependencyTrackPush returns the outcome of the latest finished push, nil when none.
LatestFinishedDependencyTrackPush(ctx context.Context) (*models.DependencyTrackLastPush, error)
// RepoSecuritySummary returns the counts-only security state of a repository, narrowed to a
// package and version when they are not empty.
RepoSecuritySummary(ctx context.Context, repoID, packageName, version string) (*models.RepoSecuritySummary, 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)
// UpsertVEXStatement records or replaces the admin VEX decision for (repo, artifact, vuln) and fills the stored row back.
UpsertVEXStatement(ctx context.Context, s *models.VEXStatement) error
// ListVEXStatements lists a repository's VEX decisions, only one artifact's when artifactID != "".
ListVEXStatements(ctx context.Context, repoID, artifactID string) ([]*models.VEXStatement, error)
// DeleteVEXStatement deletes a decision scoped to repoID; ErrVEXStatementNotFound when absent.
DeleteVEXStatement(ctx context.Context, repoID, id string) error
// DeleteSBOMReportInRepo deletes the report and returns the sha256 of its blob ("" if none).
DeleteSBOMReportInRepo(ctx context.Context, repoID, id string) (string, error)
// GPG signing keys (docs/security/signing.md). Private keys are sealed by internal/crypto.
// CreateGPGKey stores k inactive and fills ID/CreatedAt; ErrGPGKeyExists on a taken name or fingerprint.
CreateGPGKey(ctx context.Context, k *models.GPGKey) error
// CreateGPGKeyIfNone stores k as the global active key only when no key exists, under a cluster-wide lock.
CreateGPGKeyIfNone(ctx context.Context, k *models.GPGKey) (bool, error)
// ListGPGKeys lists every key without its private part.
ListGPGKeys(ctx context.Context) ([]*models.GPGKey, error)
// GetGPGKey loads one key with its sealed private part; ErrGPGKeyNotFound when absent.
GetGPGKey(ctx context.Context, id string) (*models.GPGKey, error)
// GetGPGKeyByFingerprint loads a key by fingerprint; ErrGPGKeyNotFound when absent.
GetGPGKeyByFingerprint(ctx context.Context, fingerprint string) (*models.GPGKey, error)
// DeleteGPGKey removes a key and its repository assignments; ErrGPGKeyNotFound when absent.
DeleteGPGKey(ctx context.Context, id string) error
// SetGlobalGPGKey makes id the one globally active key; ErrGPGKeyNotFound when absent.
SetGlobalGPGKey(ctx context.Context, id string) error
// ClearGlobalGPGKey leaves no key globally active.
ClearGlobalGPGKey(ctx context.Context) error
// SetRepositoryGPGKey makes keyID the signing key of one repository.
SetRepositoryGPGKey(ctx context.Context, repoID, keyID, assignedBy string) error
// ClearRepositoryGPGKey removes a repository's own key and reports whether there was one.
ClearRepositoryGPGKey(ctx context.Context, repoID string) (bool, error)
// ListGPGKeyAssignments lists every repository-to-key binding.
ListGPGKeyAssignments(ctx context.Context) ([]models.GPGKeyAssignment, error)
// ListRepositoriesForGPGKey returns the repositories bound to keyID.
ListRepositoriesForGPGKey(ctx context.Context, keyID string) ([]models.GPGSigningRepo, error)
// ListSigningRepositoriesWithoutKey returns the hosted deb/rpm repositories that follow the global key.
ListSigningRepositoriesWithoutKey(ctx context.Context) ([]models.GPGSigningRepo, error)
// ResolveGPGKeyForRepository returns the repository's own key, else the global active one, with its sealed private part; nil when unsigned.
ResolveGPGKeyForRepository(ctx context.Context, repoID string) (*models.GPGKey, error)
// GetRepositoryDependencyTrack returns the repository's Dependency-Track override, nil when none is set.
GetRepositoryDependencyTrack(ctx context.Context, repoID string) (*models.RepositoryDependencyTrack, error)
// UpsertRepositoryDependencyTrack stores the override and fills the stored row back.
UpsertRepositoryDependencyTrack(ctx context.Context, c *models.RepositoryDependencyTrack) error
// DeleteRepositoryDependencyTrack removes the override and reports whether one existed.
DeleteRepositoryDependencyTrack(ctx context.Context, repoID string) (bool, error)
// UpsertDependencyTrackPush records the push state of an artifact and fills the stored row back.
UpsertDependencyTrackPush(ctx context.Context, s *models.DependencyTrackPush) error
// GetDependencyTrackPush returns the push state of an artifact, nil when never pushed.
GetDependencyTrackPush(ctx context.Context, repoID, artifactID string) (*models.DependencyTrackPush, error)
// GetRepositoryAttestationAttach reports whether the repository attaches signed attestations to docker images as OCI referrers (false when never set).
GetRepositoryAttestationAttach(ctx context.Context, repoID string) (bool, error)
// SetRepositoryAttestationAttach stores that switch.
SetRepositoryAttestationAttach(ctx context.Context, repoID string, enabled bool) error
// ListDependencyTrackPushes lists a repository's pushes, most recently updated first.
ListDependencyTrackPushes(ctx context.Context, repoID string, limit int) ([]*models.DependencyTrackPush, error)
// CreateSystemSettingIfAbsent stores the setting unless the key exists and reports whether it was stored.
CreateSystemSettingIfAbsent(ctx context.Context, key, value string) (bool, 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, licenseReviewOnly bool, limit, offset int) ([]*models.AIAnalysis, int, error)
}
Database defines the interface for database operations.
type DatabaseConfig ¶
type DatabaseConfig struct {
// Driver names the database driver. It must be non-empty; PostgreSQL is
// the only supported database and the server always connects to it.
Driver string `yaml:"driver"`
// Host is the database host.
Host string `yaml:"host"`
// Port is the database port.
Port int `yaml:"port"`
// User is the database user.
User string `yaml:"user"`
// Password is the database password. The CHANGE_ME placeholder of the
// example files is rejected at startup.
Password string `yaml:"password"`
// Database is the database name.
Database string `yaml:"database"`
// SSLMode is the PostgreSQL sslmode; disable only for local development
// without TLS.
SSLMode string `yaml:"sslMode"`
// Options are extra libpq connection parameters. The environment form is
// comma-separated key=value pairs, merged over the YAML keys.
Options map[string]string `yaml:"options"`
// MaxOpenConns is the size of the connection pool. 0 means the driver
// default; otherwise at least 2 (a blob-lock transaction pins one
// connection and its callback needs another), and at least 4 while
// tiering.enabled is true.
MaxOpenConns int `yaml:"maxOpenConns"`
// MaxIdleConns is how many idle connections the pool keeps warm.
MaxIdleConns int `yaml:"maxIdleConns"`
// ConnMaxLifetimeMinutes is the maximum lifetime of a connection, in minutes.
ConnMaxLifetimeMinutes int `yaml:"connMaxLifetimeMinutes"`
// AuthCacheTTLMillis is how long, in milliseconds, 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"`
// ConnectTimeout is how long startup keeps retrying the initial database
// connection (capped exponential backoff) before giving up. 0 fails at the
// first error.
ConnectTimeout time.Duration `yaml:"connectTimeout"`
}
DatabaseConfig contains database connection configuration.
type DockerBlobImages ¶ added in v0.5.0
type DockerBlobImages interface {
// DockerBlobVisible reports whether the image may serve and reference the
// blob: it is linked to the image, or it predates image links and has none.
DockerBlobVisible(ctx context.Context, repoID, image, digest string) (bool, error)
// LinkDockerBlob links a blob the repository holds to the image.
LinkDockerBlob(ctx context.Context, repoID, image, digest string) error
}
DockerBlobImages is implemented by databases that track which images of a repository a blob belongs to, so RBAC path_pattern scoped to one image also scopes the blob digests it can read and reference.
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 DockerBlobTrash ¶ added in v0.8.0
type DockerBlobTrash interface {
// DockerBlobInTrash reports whether manifests of the repository reference
// the blob and every one of them is in the trash.
DockerBlobInTrash(ctx context.Context, repoID, digest string) (bool, error)
}
DockerBlobTrash is implemented by databases that can tell whether a blob is held only by trashed manifests.
type DockerCatalog ¶ added in v0.8.0
type DockerCatalog interface {
// ListDockerCatalog returns up to limit catalog names after the given one
// ("" starts at the beginning), ordered bytewise by distribution name.
ListDockerCatalog(ctx context.Context, after string, limit int) ([]*models.DockerCatalogEntry, error)
}
DockerCatalog is implemented by databases that can list the images of every docker repository for the registry's /v2/_catalog.
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 live 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.
Soft-deleted (trashed) manifests are not GC candidates (purge removes them), but their recorded references keep counting: layers and child manifests that a trashed manifest references are never collected, and a live manifest that a trashed tag points at stays "tagged" until that tag is purged, so restoring from the trash never yields a dangling reference.
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 DockerUploadSweepStore ¶ added in v0.5.0
type DockerUploadSweepStore interface {
DeleteStaleDockerUploads(ctx context.Context, cutoff time.Time) ([]string, error)
}
DockerUploadSweepStore is implemented by PostgresDB; the upload sweeper reports itself unsupported for databases that do not.
type GomodAffectedRow ¶ added in v0.5.0
type GomodAffectedRow struct {
ID string
RepositoryID string
RepoName string
ModulePath string
Version string
GoModContent string
Trashed bool
// BadBlobID and BadBlobKey identify the invalid blobs row the zip points at.
BadBlobID string
BadBlobKey string
}
GomodAffectedRow is a gomod_modules row (trashed ones included) whose zip blob row has an invalid sha256.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator applies embedded SQL migrations to a PostgreSQL database.
func NewMigrator ¶
NewMigrator returns a Migrator backed by the embedded migrations FS.
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) AddBlobReplicationProgress ¶ added in v0.9.0
func (p *PostgresDB) AddBlobReplicationProgress(ctx context.Context, copies, bytes int64) error
AddBlobReplicationProgress adds finished copies and their bytes.
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 (*PostgresDB) AddProjectMember ¶ added in v0.6.0
func (p *PostgresDB) AddProjectMember(ctx context.Context, projectID, userID, role string) error
func (*PostgresDB) AddUserToGroup ¶
func (p *PostgresDB) AddUserToGroup(ctx context.Context, userID, groupID string) error
func (*PostgresDB) ArtifactExists ¶
func (*PostgresDB) ArtifactSecurity ¶ added in v0.11.0
func (p *PostgresDB) ArtifactSecurity(ctx context.Context, repoID string, artifactIDs []string) (map[string]models.ArtifactSecurity, error)
ArtifactSecurity returns the scan state of the packages of repoID with the given listing row ids. A package that was never scanned has no entry.
func (*PostgresDB) AuthCacheGeneration ¶ added in v0.7.0
func (p *PostgresDB) AuthCacheGeneration() uint64
AuthCacheGeneration changes whenever a write made through this PostgresDB invalidated the auth cache. A value derived from permission data is current only while the generation read before deriving it is unchanged. It never changes while the cache is disabled (TTL 0).
func (*PostgresDB) AuthCacheTTL ¶ added in v0.7.0
func (p *PostgresDB) AuthCacheTTL() time.Duration
AuthCacheTTL is the configured lifetime of auth-derived cache entries (0: caching disabled). Other caches that derive from the same permission data, such as the search handler's readable-repository sets, follow it.
func (*PostgresDB) BeginBackupSnapshot ¶ added in v0.7.0
func (p *PostgresDB) BeginBackupSnapshot(ctx context.Context, leaseTTL time.Duration) (SnapshotReader, error)
BeginBackupSnapshot registers a backup lease and freezes the database. See SnapshotReader. The lease is renewed in the background until Release; if the process dies, it simply expires after leaseTTL and deferred blob deletions resume. The caller's ctx must outlive the backup: its cancellation ends the snapshot.
func (*PostgresDB) BeginStorageTierMove ¶ added in v0.7.0
func (p *PostgresDB) BeginStorageTierMove(ctx context.Context, m *models.StorageTierMove) (*models.StorageTierMove, bool, error)
BeginStorageTierMove journals the start of a move. It returns the journal row that is now authoritative for the blob and whether this call created it; an existing row (a move in flight or one awaiting cleanup) is returned as is.
func (*PostgresDB) BeginTx ¶
func (p *PostgresDB) BeginTx(ctx context.Context) (Transaction, error)
BeginTx starts a new transaction.
func (*PostgresDB) BlobDeletionDue ¶ added in v0.7.0
BlobDeletionDue reports whether the queued deletion may run right now: it exists, its grace period has passed and no live backup lease still needs the bytes. The sweeper asks again after taking the per-blob lock, because the blob may have been deleted once more (a newer deletion a backup still sees) since it was claimed.
func (*PostgresDB) BlobReferenceCount ¶
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 is still checked against the tables that reference storage objects by sha256 alone (generated metadata, deltas, release bundles, proxy cache).
func (*PostgresDB) BlobReplicationBacklog ¶ added in v0.9.0
func (p *PostgresDB) BlobReplicationBacklog(ctx context.Context, failingAttempts int) (BlobReplicationBacklog, error)
BlobReplicationBacklog counts the queue.
func (*PostgresDB) BlobReplicationReferenced ¶ added in v0.9.0
BlobReplicationReferenced reports whether the database still needs the blob.
func (*PostgresDB) BlobRowExists ¶ added in v0.4.0
func (*PostgresDB) CargoIndexStamp ¶ added in v0.6.0
func (*PostgresDB) ChangeProjectGroup ¶ added in v0.6.0
func (p *PostgresDB) ChangeProjectGroup(ctx context.Context, projectID, groupID, newRole string, createdBy *string, guard ProjectRoleGuard) error
ChangeProjectGroup attaches a group with newRole, changes its role, or detaches it (newRole == ""), in one transaction that holds the project row lock; the guard sees the group's current role ("" when not attached).
func (*PostgresDB) ChangeProjectMember ¶ added in v0.6.0
func (p *PostgresDB) ChangeProjectMember(ctx context.Context, projectID, userID, newRole string, guard ProjectRoleGuard) error
ChangeProjectMember sets, adds or removes (newRole == "") a user's project role in one transaction that holds the project row lock, so the guard, the recorded-owner and last-owner checks and the write see one consistent state and concurrent changes serialize. The guard runs first; then the invariants ErrProjectOwnerLocked and ErrLastProjectOwner apply.
func (*PostgresDB) ChargeStorageUsage ¶ added in v0.8.0
func (p *PostgresDB) ChargeStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
ChargeStorageUsage adds usage whose package row already exists (a row that was created without a reservation), past any limit: the artifact is stored, so refusing it would only desynchronise the counters. Nothing is left pending.
func (*PostgresDB) ClaimBlobDeletions ¶ added in v0.7.0
func (p *PostgresDB) ClaimBlobDeletions(ctx context.Context, limit int, claimFor time.Duration) ([]BlobDeletion, error)
ClaimBlobDeletions hands out up to limit deletions that are due. A claimed row is invisible to other callers for claimFor (so two sweepers never take the same one, and a crashed sweeper's rows come back).
func (*PostgresDB) ClaimBlobReplications ¶ added in v0.9.0
func (p *PostgresDB) ClaimBlobReplications(ctx context.Context, asOf time.Time, limit int, claimFor time.Duration) ([]BlobReplication, error)
ClaimBlobReplications hands out up to limit operations due at asOf.
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) ClaimPresignedUpload ¶ added in v0.5.0
func (p *PostgresDB) ClaimPresignedUpload(ctx context.Context, repoID, id string, lease time.Duration) (bool, error)
ClaimPresignedUpload takes the complete lease of an upload for up to lease. It reports false when the upload is already completed, does not exist, or another complete holds an unexpired lease.
func (*PostgresDB) ClearGlobalGPGKey ¶ added in v0.8.0
func (p *PostgresDB) ClearGlobalGPGKey(ctx context.Context) error
ClearGlobalGPGKey leaves no key globally active.
func (*PostgresDB) ClearRepositoryGPGKey ¶ added in v0.8.0
ClearRepositoryGPGKey removes a repository's own key (it then follows the global one) and reports whether there was one.
func (*PostgresDB) CompleteBlobReplication ¶ added in v0.9.0
func (p *PostgresDB) CompleteBlobReplication(ctx context.Context, sha256 string, version int64) (bool, error)
CompleteBlobReplication removes the claimed operation.
func (*PostgresDB) CondaRepodataStamp ¶ added in v0.6.0
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) CountBlobDeletions ¶ added in v0.7.0
func (p *PostgresDB) CountBlobDeletions(ctx context.Context) (int64, error)
CountBlobDeletions returns how many deletions are queued.
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) CountRepoPackageNames ¶ added in v0.11.0
func (p *PostgresDB) CountRepoPackageNames(ctx context.Context, repoIDs []string) (map[string]int64, error)
CountRepoPackageNames returns the number of distinct package names (as the package listing names them) of each repository in repoIDs; a repository with no packages maps to 0. It reads every package row of the repositories, so ask for one page of repositories at a time.
func (*PostgresDB) CountRepositories ¶
func (*PostgresDB) CountRepositoriesByProject ¶ added in v0.6.0
func (p *PostgresDB) CountRepositoriesByProject(ctx context.Context, projectIDs []string) (map[string]int, error)
CountRepositoriesByProject returns the number of live repositories per project for the given project IDs (projects without any are absent).
func (*PostgresDB) CountStorageTierMoves ¶ added in v0.7.0
func (p *PostgresDB) CountStorageTierMoves(ctx context.Context) (int64, error)
CountStorageTierMoves counts the journal rows (moves in flight or awaiting cleanup).
func (*PostgresDB) CountUsers ¶
func (p *PostgresDB) CountUsers(ctx context.Context) (int, error)
func (*PostgresDB) CreateBackupJob ¶
CreateBackupJob creates a new backup job.
func (*PostgresDB) CreateBootstrapAdmin ¶ added in v0.2.0
func (p *PostgresDB) CreateBootstrapAdmin(ctx context.Context, spec BootstrapAdmin) (bool, error)
CreateBootstrapAdmin creates the first admin user, binds it to the admin-all permission target and creates its optional access token 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 row takes its size from crate.SizeBytes.
func (*PostgresDB) CreateCleanupPolicy ¶
func (p *PostgresDB) CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
CreateCleanupPolicy creates a new cleanup policy.
func (*PostgresDB) CreateConanPackage ¶
func (p *PostgresDB) CreateConanPackage(ctx context.Context, pkg *models.ConanPackage) error
CreateConanPackage stores one Conan file, replacing the blob of the live row with the same (recipe revision, package id, package revision, filename).
conan_packages.blob_id is nullable; rows restored from a backup that predates the sha256 field carry only the blob key, which then stands in for the digest.
func (*PostgresDB) CreateCondaPackage ¶
func (p *PostgresDB) CreateCondaPackage(ctx context.Context, pkg *models.CondaPackage) error
CreateCondaPackage creates a new Conda package file. An empty pkg.Extension is stored as ".tar.bz2" and an empty pkg.Extra as "{}". A live row for the same (name, version, build, platform, extension) yields ErrDuplicate and is left untouched.
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. blob.Inserted reports whether the repository's row is new (false: it already held the blob).
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. m.Inserted reports whether the live row is new (false: a re-push refreshed the existing one).
func (*PostgresDB) CreateDockerUpload ¶
func (p *PostgresDB) CreateDockerUpload(ctx context.Context, upload *models.DockerUpload) error
func (*PostgresDB) CreateGPGKey ¶ added in v0.8.0
CreateGPGKey stores k (inactive) and fills ID and CreatedAt back. ErrGPGKeyExists when the name or fingerprint is taken.
func (*PostgresDB) CreateGPGKeyIfNone ¶ added in v0.8.0
CreateGPGKeyIfNone stores k as the global active key only when no key exists yet, under a cluster-wide advisory lock so replicas starting together create exactly one. It reports whether k was stored.
func (*PostgresDB) CreateGoModule ¶
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 (*PostgresDB) CreateHelmChart ¶
CreateHelmChart creates a new Helm chart.
func (*PostgresDB) CreateIvyArtifact ¶
func (p *PostgresDB) CreateIvyArtifact(ctx context.Context, artifact *models.IvyArtifact) error
CreateIvyArtifact stores an Ivy artifact; a live artifact with the same coordinates is repointed at the new blob.
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) 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) CreatePresignedUpload ¶ added in v0.5.0
func (p *PostgresDB) CreatePresignedUpload(ctx context.Context, u *models.PresignedUpload) error
CreatePresignedUpload records a presigned upload and fills u.ID and u.CreatedAt.
func (*PostgresDB) CreatePresignedUploadCapped ¶ added in v0.5.0
func (p *PostgresDB) CreatePresignedUploadCapped(ctx context.Context, u *models.PresignedUpload, maxPending int) error
CreatePresignedUploadCapped counts the user's outstanding uploads and inserts the new one in one transaction holding a per-user advisory lock, so parallel creates cannot all pass the check before any of them inserts.
func (*PostgresDB) CreateProject ¶ added in v0.6.0
func (*PostgresDB) CreateProjectRepository ¶ added in v0.6.0
func (p *PostgresDB) CreateProjectRepository(ctx context.Context, repo *models.Repository, memberIDs []string, maxRepositories int) error
CreateProjectRepository is CreateRepositoryWithMembers under the project's repository cap: with the project row locked it refuses (ErrProjectRepoLimit) when the project already holds maxRepositories live repositories, so concurrent creations cannot overshoot the cap.
func (*PostgresDB) CreateProjectToken ¶ added in v0.6.0
func (p *PostgresDB) CreateProjectToken(ctx context.Context, spec ProjectTokenSpec) (*models.Token, error)
CreateProjectToken creates, in one transaction that holds the project row lock, the service user, its membership with the token's role and the deploy token. It returns ErrProjectNotFound, ErrProjectTokenLimit or ErrProjectTokenName when the token cannot be minted.
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 (*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 ¶
CreateRpmPackage inserts an RPM package.
func (*PostgresDB) CreateRubyGem ¶
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 stores an SBT artifact; a live artifact with the same coordinates is repointed at the new blob.
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 (*PostgresDB) CreateStorageBackend ¶
func (p *PostgresDB) CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
CreateStorageBackend creates a new storage backend configuration.
func (*PostgresDB) CreateStoragePolicy ¶ added in v0.7.0
func (p *PostgresDB) CreateStoragePolicy(ctx context.Context, pol *models.StoragePolicy) error
CreateStoragePolicy inserts a policy (pol.ID must be set).
func (*PostgresDB) CreateStorageTier ¶ added in v0.7.0
func (p *PostgresDB) CreateStorageTier(ctx context.Context, t *models.StorageTier) error
CreateStorageTier inserts a tier (t.ID must be set).
func (*PostgresDB) CreateSystemSettingIfAbsent ¶ added in v0.8.0
func (p *PostgresDB) CreateSystemSettingIfAbsent(ctx context.Context, key, value string) (bool, error)
CreateSystemSettingIfAbsent stores value under key unless the key exists; it reports whether it was stored. Concurrent callers (several replicas) agree on one winner.
func (*PostgresDB) CreateToken ¶
func (*PostgresDB) CreateUser ¶
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 ¶
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), on the repository and on its project's ceiling when that has one. A repository without a quota row has nothing to decrement.
func (*PostgresDB) DeleteArtifactProperty ¶
func (p *PostgresDB) DeleteArtifactProperty(ctx context.Context, repoID, artifactID, key string) error
DeleteArtifactProperty deletes an artifact property.
func (*PostgresDB) DeleteBlobDeletion ¶ added in v0.7.0
func (p *PostgresDB) DeleteBlobDeletion(ctx context.Context, sha256, scope string) error
DeleteBlobDeletion removes a queued deletion (its bytes are gone, or it no longer applies).
func (*PostgresDB) DeleteBlobIfUnreferenced ¶ added in v0.2.0
DeleteBlobIfUnreferenced atomically removes the blobs row for sha256 and queues its bytes for deletion (BlobDeletionScopeAll), but only when no package row still references it. The check, row delete and enqueue run in one transaction under the blob advisory lock; the bytes are removed later by the sweeper, once the grace period has passed and no running backup can still need them. Returns true when the blob was removed.
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) DeleteDeclarativeObject ¶ added in v0.8.1
DeleteDeclarativeObject removes one marker and reports whether it existed.
func (*PostgresDB) DeleteDockerBlob ¶
func (p *PostgresDB) DeleteDockerBlob(ctx context.Context, repoID, digest string) error
DeleteDockerBlob removes the repository's row for the blob and returns ErrDockerRowNotFound when there was none.
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
DeleteDockerManifest permanently removes the live manifest row and returns ErrDockerRowNotFound when there was none.
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) DeleteGPGKey ¶ added in v0.8.0
func (p *PostgresDB) DeleteGPGKey(ctx context.Context, id string) error
DeleteGPGKey removes a key and its repository assignments; ErrGPGKeyNotFound when absent.
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) 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) 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) DeletePresignedUpload ¶ added in v0.5.0
func (p *PostgresDB) DeletePresignedUpload(ctx context.Context, id string) error
DeletePresignedUpload removes a presigned upload row.
func (*PostgresDB) DeleteProject ¶ added in v0.6.0
func (p *PostgresDB) DeleteProject(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) DeleteRepositoryDependencyTrack ¶ added in v0.8.0
func (p *PostgresDB) DeleteRepositoryDependencyTrack(ctx context.Context, repoID string) (bool, error)
DeleteRepositoryDependencyTrack removes the override; it reports whether one existed.
func (*PostgresDB) DeleteSBOMReportInRepo ¶ added in v0.2.0
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) DeleteStaleDockerUploads ¶ added in v0.5.0
func (p *PostgresDB) DeleteStaleDockerUploads(ctx context.Context, cutoff time.Time) ([]string, error)
DeleteStaleDockerUploads deletes the upload sessions idle since before the cutoff and returns their UUIDs.
func (*PostgresDB) DeleteStorageBackend ¶
func (p *PostgresDB) DeleteStorageBackend(ctx context.Context, id string) error
DeleteStorageBackend deletes a storage backend.
func (*PostgresDB) DeleteStoragePolicy ¶ added in v0.7.0
DeleteStoragePolicy deletes a policy; it reports whether a row was removed.
func (*PostgresDB) DeleteStorageTierIfUnused ¶ added in v0.7.0
DeleteStorageTierIfUnused deletes a non-primary tier unless something still depends on it, atomically: the tier and its backend row are locked FOR UPDATE for the whole check-and-delete, so a concurrent move (whose journal and blobs.storage_backend_id writes take a key-share lock on the backend row) either commits before the check and is seen, or waits until the delete is done. It returns "" when the tier was deleted (or was already gone) and the human-readable reason otherwise.
func (*PostgresDB) DeleteUnreferencedInvalidBlobRow ¶ added in v0.5.0
DeleteUnreferencedInvalidBlobRow deletes the blobs row id (a row with an invalid sha256) from the database only, when nothing references it any more. It never touches the storage object: for the shared "" row that object is a real module's zip, now relinked under its true digest. Returns true when the row was deleted.
func (*PostgresDB) DeleteUser ¶ added in v0.9.0
DeleteUser hard-deletes a human user. Sessions, tokens, project memberships, group links and the SSO link (external_id/provider_slug live on the row) go with it; creator/owner references are set to NULL by their foreign keys. The direct permission assignments carry no foreign key and are removed explicitly. It returns false when the user does not exist and ErrLastAdmin when the user is the last enabled admin.
func (*PostgresDB) DeleteVEXStatement ¶ added in v0.7.0
func (p *PostgresDB) DeleteVEXStatement(ctx context.Context, repoID, id string) error
DeleteVEXStatement deletes a decision scoped to repoID; ErrVEXStatementNotFound when absent.
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) DockerBlobInTrash ¶ added in v0.8.0
func (*PostgresDB) DockerBlobVisible ¶ added in v0.5.0
func (*PostgresDB) EmptySHA256BlobID ¶ added in v0.5.0
func (p *PostgresDB) EmptySHA256BlobID(ctx context.Context) (string, error)
EmptySHA256BlobID returns the id of the shared blobs row with an empty sha256 left behind by OpenArtifact <= 0.4.1, or "" when it does not exist (blobs.sha256 is unique and indexed, so this is a point lookup).
func (*PostgresDB) EnqueueBlobDeletion ¶ added in v0.7.0
func (p *PostgresDB) EnqueueBlobDeletion(ctx context.Context, sha256, scope string) error
EnqueueBlobDeletion queues the copies of sha256 named by scope for deletion (see BlobDeletionScope*). The caller has already removed what made the copies live (the blobs row, or the placement on that tier) and normally holds the per-blob lock; a caller that cannot (a write that raced a placement flip and queues its own stray copy) may enqueue without it, because the sweeper re-checks the placement under the lock before it deletes anything. The bytes stay until the grace period has passed and no live backup can still need them.
func (*PostgresDB) EnqueueBlobReplication ¶ added in v0.9.0
func (p *PostgresDB) EnqueueBlobReplication(ctx context.Context, sha256, op string) error
EnqueueBlobReplication queues op for the blob (see BlobReplicationStore).
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 if it does not exist yet) 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) ExistingPresignedUploadIDs ¶ added in v0.5.0
func (p *PostgresDB) ExistingPresignedUploadIDs(ctx context.Context, ids []string) ([]string, error)
ExistingPresignedUploadIDs returns the subset of ids that have a row. Ids that are not UUIDs cannot have one and are dropped.
func (*PostgresDB) ExtendPresignedUploadExpiry ¶ added in v0.8.0
func (p *PostgresDB) ExtendPresignedUploadExpiry(ctx context.Context, id string, expiresAt time.Time) error
ExtendPresignedUploadExpiry moves the complete deadline of a pending upload forward to expiresAt; it never shortens it.
func (*PostgresDB) FailBlobReplication ¶ added in v0.9.0
func (p *PostgresDB) FailBlobReplication(ctx context.Context, sha256 string, version int64, lastError string, nextAttempt time.Time) (bool, error)
FailBlobReplication records a failed attempt.
func (*PostgresDB) FailStorageTierMove ¶ added in v0.7.0
func (p *PostgresDB) FailStorageTierMove(ctx context.Context, sha256, message string) error
FailStorageTierMove records a failed attempt on the journal row.
func (*PostgresDB) FindConanPackageBySHA1 ¶ added in v0.8.0
func (p *PostgresDB) FindConanPackageBySHA1(ctx context.Context, repoID, sha1 string) (*models.ConanPackage, error)
FindConanPackageBySHA1 returns a live file of the repository whose content has the given SHA-1, or (nil, nil).
func (*PostgresDB) FinishReplicationVerify ¶ added in v0.9.0
func (p *PostgresDB) FinishReplicationVerify(ctx context.Context, result json.RawMessage) error
FinishReplicationVerify stores the result of the pass and ends it.
func (*PostgresDB) FinishStorageTierMove ¶ added in v0.7.0
func (p *PostgresDB) FinishStorageTierMove(ctx context.Context, sha256 string) error
FinishStorageTierMove removes the journal row once the move is complete.
func (*PostgresDB) FlipBlobPlacement ¶ added in v0.7.0
func (p *PostgresDB) FlipBlobPlacement(ctx context.Context, sha256, from, to string, verify func(ctx context.Context) error) (models.FlipOutcome, error)
FlipBlobPlacement atomically repoints blobs.storage_backend_id from `from` to `to` and marks the journal row flipped, in ONE transaction under the per-blob advisory lock that SafeDeleteBlob and uploaders take (WithBlobLock). It is the only place a placement changes: either the whole flip commits or nothing did, so a crash leaves exactly one authoritative placement.
verify runs once the blob lock is held and before the placement changes; a non-nil error aborts the flip. The mover uses it to prove the target copy still exists: every path that removes a copy (uploaders settling a race, SafeDeleteBlob) does so under the same lock, so a copy confirmed here cannot vanish before the flip commits.
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) GetBackupJob ¶
GetBackupJob retrieves a backup job by ID.
func (*PostgresDB) GetBlobPlacement ¶ added in v0.7.0
func (p *PostgresDB) GetBlobPlacement(ctx context.Context, sha256 string) (string, int64, bool, error)
GetBlobPlacement returns where the blob lives ("" = primary store) and its size. found is false when there is no blobs row.
func (*PostgresDB) GetBlobReplication ¶ added in v0.9.0
func (p *PostgresDB) GetBlobReplication(ctx context.Context, sha256 string) (*BlobReplication, error)
GetBlobReplication returns the queued operation of the blob, nil when none.
func (*PostgresDB) GetBlobReplicationState ¶ added in v0.9.0
func (p *PostgresDB) GetBlobReplicationState(ctx context.Context) (BlobReplicationState, error)
GetBlobReplicationState reads the singleton state.
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 (*PostgresDB) GetComponentByID ¶
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) GetComponentBySHA256 ¶ added in v0.5.0
func (p *PostgresDB) GetComponentBySHA256(ctx context.Context, repoID, sha256 string) (*models.Component, error)
GetComponentBySHA256 finds a live rpm or deb package in a repository by the sha256 of its blob using a single-row lookup per table.
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 string, key models.ConanFileKey) (*models.ConanPackage, error)
GetConanPackage returns the live file stored under key, or (nil, nil).
func (*PostgresDB) GetCondaPackageFile ¶ added in v0.5.0
func (p *PostgresDB) GetCondaPackageFile(ctx context.Context, repoID, name, version, buildString, platform, extension string) (*models.CondaPackage, error)
GetCondaPackageFile returns the live package file with this exact name, version, build, platform and extension, or nil.
func (*PostgresDB) GetDB ¶
func (p *PostgresDB) GetDB() *sql.DB
GetDB returns the underlying sql.DB connection.
func (*PostgresDB) GetDebBlobInfo ¶ added in v0.2.0
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) GetDebianDistributionsByRepo ¶
func (p *PostgresDB) GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)
func (*PostgresDB) GetDebianPackageByFilename ¶
func (*PostgresDB) GetDebianPackagesByDistComp ¶
func (*PostgresDB) GetDependencyTrackPush ¶ added in v0.8.0
func (p *PostgresDB) GetDependencyTrackPush(ctx context.Context, repoID, artifactID string) (*models.DependencyTrackPush, error)
GetDependencyTrackPush returns the push state of an artifact, nil when it was never pushed.
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 (*PostgresDB) GetDockerUpload ¶
func (p *PostgresDB) GetDockerUpload(ctx context.Context, repositoryID, uploadUUID string) (*models.DockerUpload, error)
func (*PostgresDB) GetGPGKey ¶ added in v0.8.0
GetGPGKey loads one key including its sealed private part; ErrGPGKeyNotFound when absent.
func (*PostgresDB) GetGPGKeyByFingerprint ¶ added in v0.8.0
func (p *PostgresDB) GetGPGKeyByFingerprint(ctx context.Context, fingerprint string) (*models.GPGKey, error)
GetGPGKeyByFingerprint loads a key by its (upper-case hex) fingerprint; ErrGPGKeyNotFound when absent.
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 (*PostgresDB) GetGroupByName ¶
func (*PostgresDB) GetGroupMetadataState ¶ added in v0.8.0
func (p *PostgresDB) GetGroupMetadataState(ctx context.Context, groupID string) (*models.GroupMetadataState, error)
GetGroupMetadataState returns the state row of a group, nil when it has none.
func (*PostgresDB) GetGroupPackageOwner ¶ added in v0.8.0
func (p *PostgresDB) GetGroupPackageOwner(ctx context.Context, groupID, path string) (string, bool, error)
GetGroupPackageOwner returns the member repository that owns path (a Debian pool path or an RPM location) in the merged index of the group, ok=false when the index lists no such file.
func (*PostgresDB) GetHelmChart ¶
func (*PostgresDB) GetIvyArtifact ¶
func (p *PostgresDB) GetIvyArtifact(ctx context.Context, repoID, organisation, module, revision, artifactName, artifactExt string) (*models.IvyArtifact, error)
func (*PostgresDB) GetLatestSnapshot ¶
func (p *PostgresDB) GetLatestSnapshot(ctx context.Context, repoID, groupID, artifactID, version string) (*models.MavenArtifact, error)
func (*PostgresDB) GetLatestSnapshotFile ¶ added in v0.5.0
func (p *PostgresDB) GetLatestSnapshotFile(ctx context.Context, repoID, groupID, artifactID, version, classifier, extension 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) GetMavenArtifactsByGAV ¶
func (p *PostgresDB) GetMavenArtifactsByGAV(ctx context.Context, repoID, groupID, artifactID, version string) ([]*models.MavenArtifact, error)
func (*PostgresDB) GetNPMDistTags ¶
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) GetNPMVersionStates ¶ added in v0.6.0
func (p *PostgresDB) GetNPMVersionStates(ctx context.Context, packageID string) ([]models.NPMVersionState, 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 (*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) GetPackageDelta ¶
func (p *PostgresDB) GetPackageDelta(ctx context.Context, repoID, fromSHA256, toSHA256 string) (*models.PackageDelta, error)
func (*PostgresDB) GetPasswordExpiry ¶ added in v0.11.0
GetPasswordExpiry returns the password expiry of a user that must still change its password; nil when there is none.
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) GetPresignedUpload ¶ added in v0.5.0
func (p *PostgresDB) GetPresignedUpload(ctx context.Context, repoID, id string) (*models.PresignedUpload, error)
GetPresignedUpload returns the presigned upload id of repository repoID, or nil, nil when there is none.
func (*PostgresDB) GetProject ¶ added in v0.6.0
func (*PostgresDB) GetProjectByName ¶ added in v0.6.0
func (*PostgresDB) GetProjectGroup ¶ added in v0.6.0
func (p *PostgresDB) GetProjectGroup(ctx context.Context, projectID, groupID string) (*models.ProjectGroup, error)
func (*PostgresDB) GetProjectMember ¶ added in v0.6.0
func (p *PostgresDB) GetProjectMember(ctx context.Context, projectID, userID string) (*models.ProjectMember, error)
func (*PostgresDB) GetProjectQuota ¶ added in v0.6.0
func (p *PostgresDB) GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
GetProjectQuota returns the project's storage ceiling; a project that never had one reads as unlimited (zero limits).
func (*PostgresDB) GetProjectUsage ¶ added in v0.6.0
func (p *PostgresDB) GetProjectUsage(ctx context.Context, projectID string) (*models.ProjectUsage, error)
GetProjectUsage reports a project's usage: the sum of its repositories' counters (always available, whether or not a ceiling is set), the ceiling, and one line per live repository, largest first.
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) GetPyPIPackageByFilename ¶ added in v0.5.0
func (p *PostgresDB) GetPyPIPackageByFilename(ctx context.Context, repoID, filename string) (*models.PyPIPackage, error)
func (*PostgresDB) GetRPMRepo ¶
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) GetRepoComponentDetail ¶ added in v0.11.0
func (p *PostgresDB) GetRepoComponentDetail(ctx context.Context, repoID, id string) (*models.ComponentDetail, error)
GetRepoComponentDetail resolves a row id of the package listing (any format) to the row with the metadata its table stores, scoped to repoID. It returns nil, nil when the id is not in that repository or 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) GetRepositoryAttestationAttach ¶ added in v0.8.0
func (p *PostgresDB) GetRepositoryAttestationAttach(ctx context.Context, repoID string) (bool, error)
GetRepositoryAttestationAttach reports whether the repository attaches signed attestations to its docker images as OCI referrers; false when never set.
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) GetRepositoryDependencyTrack ¶ added in v0.8.0
func (p *PostgresDB) GetRepositoryDependencyTrack(ctx context.Context, repoID string) (*models.RepositoryDependencyTrack, error)
GetRepositoryDependencyTrack returns the repository's override, nil when none is set.
func (*PostgresDB) GetRepositoryUsage ¶ added in v0.11.0
func (p *PostgresDB) GetRepositoryUsage(ctx context.Context, repoID string) (*models.RepositoryUsage, error)
GetRepositoryUsage counts the packages and versions a repository holds and when the newest version was created. It scans the repository's package rows: call it for one repository on demand.
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 (*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) 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 (*PostgresDB) GetSessionSSO ¶ added in v0.8.0
func (p *PostgresDB) GetSessionSSO(ctx context.Context, tokenHash string) (*models.SessionSSO, 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) GetStoragePolicy ¶ added in v0.7.0
func (p *PostgresDB) GetStoragePolicy(ctx context.Context, id string) (*models.StoragePolicy, error)
GetStoragePolicy returns a policy by id, or nil when there is none.
func (*PostgresDB) GetStorageTierByName ¶ added in v0.7.0
func (p *PostgresDB) GetStorageTierByName(ctx context.Context, name string) (*models.StorageTier, error)
GetStorageTierByName returns the named tier, or nil when there is none.
func (*PostgresDB) GetSystemSetting ¶
GetSystemSetting retrieves a system setting by key.
func (*PostgresDB) GetTokenByHash ¶
GetTokenByHash returns the token with the given hash, from the auth cache when fresh.
func (*PostgresDB) GetTokenByHashUncached ¶ added in v0.4.0
func (*PostgresDB) GetTokenByID ¶
func (*PostgresDB) GetTrashItem ¶ added in v0.5.0
func (p *PostgresDB) GetTrashItem(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
GetTrashItem implements TrashStore.
func (*PostgresDB) GetUserByEmail ¶
func (*PostgresDB) GetUserByExternalID ¶
func (*PostgresDB) GetUserByID ¶
GetUserByID returns the user with the given ID, from the auth cache when fresh.
func (*PostgresDB) GetUserByIDUncached ¶ added in v0.4.0
func (*PostgresDB) GetUserByUsername ¶
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 ¶
GetWebhook retrieves a webhook by ID.
func (*PostgresDB) HelmIndexStamp ¶ added in v0.6.0
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) InsertAuditLog ¶
func (*PostgresDB) InsertRawArtifactIfAbsent ¶ added in v0.5.0
func (p *PostgresDB) InsertRawArtifactIfAbsent(ctx context.Context, artifact *models.RawArtifact) (bool, error)
InsertRawArtifactIfAbsent inserts a raw artifact only when no live row exists at its path, in one atomic statement. It reports whether the row was inserted; false means the path is taken and nothing was changed.
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) LatestFinishedDependencyTrackPush ¶ added in v0.11.0
func (p *PostgresDB) LatestFinishedDependencyTrackPush(ctx context.Context) (*models.DependencyTrackLastPush, error)
LatestFinishedDependencyTrackPush returns the outcome of the most recent finished push of any artifact, nil when none finished yet.
func (*PostgresDB) LinkDockerBlob ¶ added in v0.5.0
func (p *PostgresDB) LinkDockerBlob(ctx context.Context, repoID, image, digest string) error
func (*PostgresDB) ListAIAnalyses ¶
func (p *PostgresDB) ListAIAnalyses(ctx context.Context, repoID string, status string, licenseReviewOnly bool, limit, offset int) ([]*models.AIAnalysis, int, error)
ListAIAnalyses lists AI analyses for a repository with optional status and REVIEW_REQUIRED license filters.
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) ListAllProjects ¶ added in v0.6.0
func (*PostgresDB) ListAllSSOProviders ¶
func (p *PostgresDB) ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
func (*PostgresDB) ListAllTokens ¶
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 ¶
ListBackupJobs lists backup jobs with a limit.
func (*PostgresDB) ListBlobRefs ¶ added in v0.7.0
func (p *PostgresDB) ListBlobRefs(ctx context.Context, shas []string) (map[string][]models.BlobRef, error)
ListBlobRefs returns, per blob, the repository entries referencing it (repository name, format and artifact path).
func (*PostgresDB) ListBlobSHAs ¶ added in v0.9.0
ListBlobSHAs returns one keyset page of the blobs table.
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) ListCargoIndexVersions ¶ added in v0.6.0
func (p *PostgresDB) ListCargoIndexVersions(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) ListConanRecipeFiles ¶ added in v0.5.0
func (p *PostgresDB) ListConanRecipeFiles(ctx context.Context, repoID, name, version, userChannel string) ([]*models.ConanPackage, error)
ListConanRecipeFiles returns every live file of one recipe (all its recipe and package revisions), oldest first.
func (*PostgresDB) ListConanRecipes ¶ added in v0.5.0
func (p *PostgresDB) ListConanRecipes(ctx context.Context, repoID string) ([]models.ConanRecipe, error)
ListConanRecipes returns the distinct recipes that have at least one file.
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) ListDeclarativeObjects ¶ added in v0.8.1
func (p *PostgresDB) ListDeclarativeObjects(ctx context.Context) ([]models.DeclarativeObject, error)
ListDeclarativeObjects returns every ownership marker, ordered by kind and name.
func (*PostgresDB) ListDependencyTrackPushes ¶ added in v0.8.0
func (p *PostgresDB) ListDependencyTrackPushes(ctx context.Context, repoID string, limit int) ([]*models.DependencyTrackPush, error)
ListDependencyTrackPushes lists the pushes of a repository, most recently updated first.
func (*PostgresDB) ListDockerBlobs ¶
func (p *PostgresDB) ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)
func (*PostgresDB) ListDockerCatalog ¶ added in v0.8.0
func (p *PostgresDB) ListDockerCatalog(ctx context.Context, after string, limit int) ([]*models.DockerCatalogEntry, error)
func (*PostgresDB) ListDockerGCBlobs ¶ added in v0.4.0
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 (*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) ListExpiredPresignedUploads ¶ added in v0.5.0
ListExpiredPresignedUploads returns up to limit ids of presigned uploads past their complete deadline.
func (*PostgresDB) ListExpiredTrash ¶ added in v0.5.0
ListExpiredTrash implements TrashStore.
func (*PostgresDB) ListGPGKeyAssignments ¶ added in v0.8.0
func (p *PostgresDB) ListGPGKeyAssignments(ctx context.Context) ([]models.GPGKeyAssignment, error)
ListGPGKeyAssignments lists every repository-to-key binding.
func (*PostgresDB) ListGPGKeys ¶ added in v0.8.0
ListGPGKeys lists every key without its private part.
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) ListGomodAffectedRows ¶ added in v0.5.0
func (p *PostgresDB) ListGomodAffectedRows(ctx context.Context) ([]GomodAffectedRow, error)
ListGomodAffectedRows returns every gomod_modules row whose zip blob row has a sha256 that is not 64 lowercase hex characters.
func (*PostgresDB) ListGomodSiblingZipKeys ¶ added in v0.5.0
func (p *PostgresDB) ListGomodSiblingZipKeys(ctx context.Context) ([]string, error)
ListGomodSiblingZipKeys returns the digests of valid zip blobs of other gomod_modules rows that share module path and version with an affected row (the same release published in another repository after the upgrade).
func (*PostgresDB) ListGroupMemberRepositories ¶ added in v0.6.0
func (p *PostgresDB) ListGroupMemberRepositories(ctx context.Context, groupRepoID string) ([]*models.Repository, error)
func (*PostgresDB) ListGroupMembers ¶
func (p *PostgresDB) ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
func (*PostgresDB) ListGroups ¶
func (*PostgresDB) ListGroupsByUser ¶
ListGroupsByUser returns the groups of a user, from the auth cache when fresh.
func (*PostgresDB) ListGroupsByUserUncached ¶ added in v0.4.0
func (*PostgresDB) ListGroupsOfMember ¶ added in v0.8.0
func (p *PostgresDB) ListGroupsOfMember(ctx context.Context, memberRepoID string) ([]*models.Repository, error)
func (*PostgresDB) ListHelmCharts ¶
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) ListMavenGARefs ¶ added in v0.9.0
func (p *PostgresDB) ListMavenGARefs(ctx context.Context, repoID, groupID, artifactID string) (*models.MavenGARefs, error)
ListMavenGARefs loads the versions and snapshot files of one group:artifact in a single narrow query (no artifact ids, paths or checksum join).
func (*PostgresDB) ListMetadataGroupsOfMember ¶ added in v0.8.0
func (p *PostgresDB) ListMetadataGroupsOfMember(ctx context.Context, memberRepoID string) ([]string, error)
ListMetadataGroupsOfMember returns the ids of the deb/rpm group repositories that list memberRepoID as a member.
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) ListPackageDeltas ¶
func (p *PostgresDB) ListPackageDeltas(ctx context.Context, repoID, toSHA256 string) ([]*models.PackageDelta, error)
ListPackageDeltas returns the deltas that target toSHA256. A delta whose source package is in the trash is hidden (it would reveal the trashed file's sha256 and name) and reappears when the source is restored; a source that still has a live row (same blob in another row) keeps its deltas visible.
func (*PostgresDB) ListPermissionAssignments ¶ added in v0.6.0
func (p *PostgresDB) ListPermissionAssignments(ctx context.Context) ([]*models.PermissionAssignment, error)
ListPermissionAssignments returns every permission assignment (user and group principals alike).
func (*PostgresDB) ListPermissionAssignmentsForTarget ¶ added in v0.8.1
func (p *PostgresDB) ListPermissionAssignmentsForTarget(ctx context.Context, targetID string) ([]models.PermissionAssignmentView, error)
ListPermissionAssignmentsForTarget returns the assignments of one permission target with principal names, ordered by type then name.
func (*PostgresDB) ListPermissionTargets ¶
func (p *PostgresDB) ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)
func (*PostgresDB) ListProjectCleanupPolicies ¶ added in v0.6.0
func (p *PostgresDB) ListProjectCleanupPolicies(ctx context.Context, projectID string) ([]*models.CleanupPolicy, error)
ListProjectCleanupPolicies lists the default cleanup policies of a project.
func (*PostgresDB) ListProjectCleanupRepositories ¶ added in v0.6.0
func (p *PostgresDB) ListProjectCleanupRepositories(ctx context.Context, projectID string) ([]string, error)
ListProjectCleanupRepositories returns the IDs of the live hosted repositories a project default policy applies to: those without an enabled repository-level policy.
func (*PostgresDB) ListProjectGrantsByUser ¶ added in v0.6.0
func (p *PostgresDB) ListProjectGrantsByUser(ctx context.Context, userID string) ([]*models.ProjectGrant, error)
ListProjectGrantsByUser returns the project grants of a user (see models.ProjectGrant), from the auth cache when fresh.
func (*PostgresDB) ListProjectGroups ¶ added in v0.6.0
func (p *PostgresDB) ListProjectGroups(ctx context.Context, projectID string) ([]*models.ProjectGroup, error)
func (*PostgresDB) ListProjectMembers ¶ added in v0.6.0
func (p *PostgresDB) ListProjectMembers(ctx context.Context, projectID string) ([]*models.ProjectMember, error)
func (*PostgresDB) ListProjectRepositories ¶ added in v0.6.0
func (p *PostgresDB) ListProjectRepositories(ctx context.Context, projectID string, page, limit int) ([]*models.Repository, int, error)
ListProjectRepositories returns one page of the project's live repositories, newest first, and their total number.
func (*PostgresDB) ListProjectStats ¶ added in v0.11.0
func (p *PostgresDB) ListProjectStats(ctx context.Context, projectIDs []string) (map[string]*models.ProjectStats, error)
ListProjectStats returns the member count, live usage and size ceiling of each given project in one query (projects that do not exist are absent).
func (*PostgresDB) ListProjectTokens ¶ added in v0.6.0
func (p *PostgresDB) ListProjectTokens(ctx context.Context, projectID string, createdBy *string) ([]*models.Token, error)
ListProjectTokens returns the project's tokens that are not revoked, newest first. createdBy limits them to the tokens minted by that user.
func (*PostgresDB) ListProjects ¶ added in v0.6.0
func (*PostgresDB) ListPromotionCandidates ¶ added in v0.7.0
func (p *PostgresDB) ListPromotionCandidates(ctx context.Context, backendIDs []string, after string, limit int) ([]models.BlobFacts, error)
ListPromotionCandidates returns blobs placed on one of backendIDs that were read after they arrived there (last_accessed_at > tier_changed_at), ordered by sha256 after the cursor, skipping blobs with a move in flight.
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) ListPyPIPackageNames ¶ added in v0.6.0
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) ListQuotaOverview ¶ added in v0.11.0
func (p *PostgresDB) ListQuotaOverview(ctx context.Context, params models.QuotaListParams) ([]*models.QuotaOverview, int, error)
ListQuotaOverview returns one page of the instance-wide quota overview, largest usage first, and the number of matching lines.
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) ListRecentPackages ¶ added in v0.11.0
func (p *PostgresDB) ListRecentPackages(ctx context.Context, repoIDs []string, limit int) ([]models.RecentPackage, error)
ListRecentPackages returns the newest package versions across the repositories in repoIDs, newest first, at most limit of them. Multi-file versions appear once.
func (*PostgresDB) ListRecoverableStorageTierMoves ¶ added in v0.7.0
func (p *PostgresDB) ListRecoverableStorageTierMoves(ctx context.Context, maxAttempts int, retryAfter time.Duration, limit int) ([]*models.StorageTierMove, error)
ListRecoverableStorageTierMoves returns journal rows that still have attempts left, or that last failed more than retryAfter ago.
func (*PostgresDB) ListReleaseBundles ¶
func (p *PostgresDB) ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)
func (*PostgresDB) ListRepoPackageRollup ¶ added in v0.11.0
func (p *PostgresDB) ListRepoPackageRollup(ctx context.Context, opts models.PackageRollupOptions) ([]models.PackageRollup, int, error)
ListRepoPackageRollup lists the packages (format, name) of a repository, one row each: the latest version, the version count and the latest version's size. It returns the requested page and the total number of matching packages.
The first stage groups the narrow rows of every table, the second reads the sizes of the page's packages only (see rollupQuery).
func (*PostgresDB) ListRepositories ¶
func (p *PostgresDB) ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)
func (*PostgresDB) ListRepositoriesForGPGKey ¶ added in v0.8.0
func (p *PostgresDB) ListRepositoriesForGPGKey(ctx context.Context, keyID string) ([]models.GPGSigningRepo, error)
ListRepositoriesForGPGKey returns the repositories bound to keyID.
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) ListRubyGemSpecs ¶ added in v0.6.0
func (*PostgresDB) ListRubyGemVersions ¶
func (*PostgresDB) ListRubyGems ¶
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) ListSecurityFindings ¶ added in v0.11.0
func (p *PostgresDB) ListSecurityFindings(ctx context.Context, params models.FindingListParams) (*models.FindingPage, error)
ListSecurityFindings returns one keyset page of the findings of every requested type, worst severity first, then newest scan, then id.
func (*PostgresDB) ListSigningRepositoriesWithoutKey ¶ added in v0.8.0
func (p *PostgresDB) ListSigningRepositoriesWithoutKey(ctx context.Context) ([]models.GPGSigningRepo, error)
ListSigningRepositoriesWithoutKey returns the hosted deb/rpm repositories that have no key of their own, i.e. follow the global key.
func (*PostgresDB) ListStaleMetadataGroups ¶ added in v0.8.0
func (p *PostgresDB) ListStaleMetadataGroups(ctx context.Context) ([]string, error)
ListStaleMetadataGroups returns the deb/rpm group repositories whose merged metadata is stale or was never generated.
func (*PostgresDB) ListStorageBackends ¶
func (p *PostgresDB) ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)
ListStorageBackends lists all storage backends.
func (*PostgresDB) ListStoragePolicies ¶ added in v0.7.0
func (p *PostgresDB) ListStoragePolicies(ctx context.Context) ([]*models.StoragePolicy, error)
ListStoragePolicies lists every policy in evaluation order.
func (*PostgresDB) ListStorageQuotas ¶ added in v0.6.0
func (p *PostgresDB) ListStorageQuotas(ctx context.Context) ([]*models.StorageQuota, error)
ListStorageQuotas returns every repository's quota row.
func (*PostgresDB) ListStorageTierMoves ¶ added in v0.7.0
func (p *PostgresDB) ListStorageTierMoves(ctx context.Context, limit int) ([]*models.StorageTierMove, error)
ListStorageTierMoves returns the most recently touched journal rows.
func (*PostgresDB) ListStorageTiers ¶ added in v0.7.0
func (p *PostgresDB) ListStorageTiers(ctx context.Context) ([]*models.StorageTier, error)
ListStorageTiers lists every tier, hottest rank first.
func (*PostgresDB) ListTokensByUser ¶
func (*PostgresDB) ListTrash ¶ added in v0.5.0
func (p *PostgresDB) ListTrash(ctx context.Context, f models.TrashFilter) ([]*models.TrashItem, int, error)
ListTrash implements TrashStore.
func (*PostgresDB) ListUnifiedTokens ¶ added in v0.11.0
func (p *PostgresDB) ListUnifiedTokens(ctx context.Context, params models.TokenListParams) ([]*models.TokenListItem, int, error)
ListUnifiedTokens returns one page of the unified token list (personal, project and federation tokens), newest first, and the number of tokens the caller may see that match the filters.
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, after string, scan, limit int) ([]string, string, error)
ListUnreferencedBlobs scans one window of at most scan blobs rows whose sha256 sorts after the cursor and returns up to limit of them 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). next is the cursor for the following call and is "" once the end of the table was reached, i.e. the scan wraps around.
Bounding the window (instead of evaluating the reference check for every old blob on every call) keeps the cost of a pass independent of table size, and advancing by sha256 means orphans that cannot be removed never block the ones behind them. Used to reclaim storage after repository deletion cascades its package rows.
func (*PostgresDB) ListUserGroupMemberships ¶ added in v0.6.0
ListUserGroupMemberships returns every user-to-group membership, including the ones an SSO login manages.
func (*PostgresDB) ListUsersByGroup ¶
func (*PostgresDB) ListVEXStatements ¶ added in v0.7.0
func (p *PostgresDB) ListVEXStatements(ctx context.Context, repoID, artifactID string) ([]*models.VEXStatement, error)
ListVEXStatements lists the decisions of a repository, optionally only those of one artifact (artifactID != "").
func (*PostgresDB) ListVulnScanOverview ¶ added in v0.7.0
func (p *PostgresDB) ListVulnScanOverview(ctx context.Context, params models.VulnScanListParams) (*models.VulnScanOverviewPage, error)
ListVulnScanOverview returns one page of vulnerability scans across all repositories, worst first. See vulnOverviewQuery.
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 ¶
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) MarkGroupMetadataStale ¶ added in v0.8.0
func (p *PostgresDB) MarkGroupMetadataStale(ctx context.Context, groupID string) error
MarkGroupMetadataStale records that the merged metadata of a deb/rpm group must be regenerated, creating its state row on first use.
func (*PostgresDB) MarkPackumentStale ¶
func (p *PostgresDB) MarkPackumentStale(ctx context.Context, packageID string) error
func (*PostgresDB) MarkPresignedUploadCompleted ¶ added in v0.5.0
func (p *PostgresDB) MarkPresignedUploadCompleted(ctx context.Context, id, artifactID string) error
MarkPresignedUploadCompleted records that the upload produced artifactID.
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) MoveRepositoryToProject ¶ added in v0.6.0
func (p *PostgresDB) MoveRepositoryToProject(ctx context.Context, repoID, toProjectID string, maxRepositories int) error
MoveRepositoryToProject reassigns a repository to another project, under the target's repository cap when maxRepositories > 0 (ErrProjectRepoLimit). The repository's storage usage moves between the projects' ceilings in the same transaction and must fit the target's (ErrProjectQuotaExceeded).
func (*PostgresDB) Ping ¶
func (p *PostgresDB) Ping(ctx context.Context) error
Ping checks if the database is accessible.
func (*PostgresDB) PoolStat ¶ added in v0.9.0
func (p *PostgresDB) PoolStat() *pgxpool.Stat
PoolStat reads the statistics of the shared pgx pool (for the openartifact_db_pool_* metrics). It must not be called on a backup snapshot view, which has no pool of its own.
func (*PostgresDB) PruneMavenMetadata ¶ added in v0.5.0
func (p *PostgresDB) PruneMavenMetadata(ctx context.Context, repositoryID, dir string, keep []string) ([]string, error)
PruneMavenMetadata deletes the generated maven-metadata.xml rows below the directory dir (e.g. "com/example/app/"): the artifact's own maven-metadata.xml and the one of each snapshot version directory, except the paths in keep. The regeneration calls it with the paths it just wrote, so metadata of an artifact (or snapshot version) that has no live file left disappears instead of advertising versions that were deleted or trashed. The blob shas of the deleted rows are returned so the caller can reclaim the objects.
func (*PostgresDB) PruneRepoDeltas ¶ added in v0.6.0
func (p *PostgresDB) PruneRepoDeltas(ctx context.Context, repoID string, maxCount int, maxBytes int64) ([]string, error)
PruneRepoDeltas deletes the oldest package_deltas rows of a repository until at most maxCount rows totalling at most maxBytes remain, and returns the delta blob sha256s of the deleted rows (callers release them through storage.SafeDeleteBlob once the rows are gone).
func (*PostgresDB) PurgeAuditLogsBefore ¶ added in v0.10.0
func (p *PostgresDB) PurgeAuditLogsBefore(ctx context.Context, cutoff time.Time, limit int) (int64, error)
PurgeAuditLogsBefore implements AuditRetentionStore.
func (*PostgresDB) PurgeExpiredBackupLeases ¶ added in v0.7.0
func (p *PostgresDB) PurgeExpiredBackupLeases(ctx context.Context) (int64, error)
PurgeExpiredBackupLeases removes the leases of backups that stopped renewing them (crashed). An expired lease already blocks nothing; this only tidies up.
func (*PostgresDB) PurgeTrash ¶ added in v0.5.0
func (p *PostgresDB) PurgeTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashPurgeResult, error)
PurgeTrash implements TrashStore.
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 it, is accounted for by its quota_pending entry, and the fix adds only the difference to the counter's current value, so the result is exact at every instant (entries older than quotaPendingReserveTTL and quotaPendingReleaseTTL are abandoned operations and do not count).
func (*PostgresDB) RegenKeys ¶ added in v0.5.0
func (p *PostgresDB) RegenKeys(ctx context.Context, kind models.TrashKind, id string) (string, string, error)
RegenKeys implements TrashStore.
func (*PostgresDB) ReleaseBlobReplication ¶ added in v0.9.0
func (p *PostgresDB) ReleaseBlobReplication(ctx context.Context, sha256 string, version int64) error
ReleaseBlobReplication gives a claimed operation back unprocessed.
func (*PostgresDB) ReleasePresignedUpload ¶ added in v0.5.0
func (p *PostgresDB) ReleasePresignedUpload(ctx context.Context, id string) error
ReleasePresignedUpload gives up the lease of an upload that was not completed.
func (*PostgresDB) RelinkGomodZips ¶ added in v0.5.0
func (p *PostgresDB) RelinkGomodZips(ctx context.Context, sha256 string, size int64, rowIDs []string) (int64, error)
RelinkGomodZips upserts the blobs row for the zip with digest sha256 and points the given gomod_modules rows at it, but only rows that still reference badBlobID (so a concurrent change is never overwritten). It runs under the same per-blob advisory lock as uploads and SafeDeleteBlob and returns how many rows were relinked.
func (*PostgresDB) RemoveBundleItem ¶
func (p *PostgresDB) RemoveBundleItem(ctx context.Context, bundleID, sha256 string) error
RemoveBundleItem deletes an item only while the bundle is still a draft. The draft check and the delete are one statement that row-locks the bundle, so a concurrent seal cannot slip between them; a non-draft bundle yields ErrBundleNotDraft. Removing an item that is already gone is a no-op.
func (*PostgresDB) RemoveUserFromGroup ¶
func (p *PostgresDB) RemoveUserFromGroup(ctx context.Context, userID, groupID string) error
func (*PostgresDB) RepairBootstrapAdmin ¶ added in v0.2.0
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) RepoCatalogStats ¶ added in v0.11.0
func (p *PostgresDB) RepoCatalogStats(ctx context.Context, repoIDs []string, withLastPublished bool) (map[string]models.RepoStats, error)
RepoCatalogStats returns the catalog figures of the repositories in repoIDs (a repository without any is present with zero values): stored size and quota and the security aggregates, plus the time of the newest package when withLastPublished. It runs one query of each kind for the whole set, however many repositories it holds. The package count is separate (CountRepoPackageNames), and the newest-package time is optional: both probe every package table, which the list filters do not need.
func (*PostgresDB) RepoSecuritySummary ¶ added in v0.11.0
func (p *PostgresDB) RepoSecuritySummary(ctx context.Context, repoID, packageName, version string) (*models.RepoSecuritySummary, error)
RepoSecuritySummary returns the counts-only security state of a repository, narrowed to a package (and version) when given.
func (*PostgresDB) RequestReplicationVerify ¶ added in v0.9.0
func (p *PostgresDB) RequestReplicationVerify(ctx context.Context) (bool, error)
RequestReplicationVerify asks for a verify pass.
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), and, when the repository's project has a ceiling, to the project's counters too: the upload must fit both levels, otherwise nothing is reserved. It returns false, nil when a quota would be exceeded.
func (*PostgresDB) ResolveAuditNames ¶ added in v0.11.0
func (p *PostgresDB) ResolveAuditNames(ctx context.Context, refs models.AuditNameRefs) (*models.AuditNames, error)
ResolveAuditNames looks up the display names of the entities one audit page refers to, one query for all kinds. Entities that no longer exist are absent from the result.
func (*PostgresDB) ResolveGPGKeyForRepository ¶ added in v0.8.0
func (p *PostgresDB) ResolveGPGKeyForRepository(ctx context.Context, repoID string) (*models.GPGKey, error)
ResolveGPGKeyForRepository returns the key that signs a repository's metadata (its own, else the global active one) with its sealed private part, or nil when nothing signs it.
func (*PostgresDB) RestoreTrash ¶ added in v0.5.0
func (p *PostgresDB) RestoreTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
RestoreTrash implements TrashStore.
func (*PostgresDB) RevokeProjectToken ¶ added in v0.6.0
func (p *PostgresDB) RevokeProjectToken(ctx context.Context, projectID, tokenID string) (bool, error)
RevokeProjectToken revokes a token of the project and disables its service user in one transaction; the auth cache is dropped so the token stops working at once. It reports false when the project has no such active token.
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) RubyGemsSpecsStamp ¶ added in v0.6.0
func (*PostgresDB) SaveReplicationVerifyProgress ¶ added in v0.9.0
func (p *PostgresDB) SaveReplicationVerifyProgress(ctx context.Context, cursor string, run json.RawMessage) (bool, error)
SaveReplicationVerifyProgress stores the cursor and counters of the running pass.
func (*PostgresDB) ScanTierCandidates ¶ added in v0.7.0
func (p *PostgresDB) ScanTierCandidates(ctx context.Context, after string, window int, clauses []models.TierScanClause) ([]models.BlobFacts, string, int, error)
ScanTierCandidates examines one window of at most `window` blobs rows after the cursor and returns those matching any clause (and not already being moved). next is the cursor for the following call, "" once the end of the table was reached; scanned is how many rows the window covered.
func (*PostgresDB) SealReleaseBundle ¶ added in v0.2.0
func (p *PostgresDB) SealReleaseBundle(ctx context.Context, bundleID, sealedBy string, sealedAt time.Time, sig *models.BundleSignature) (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), or, when sig is given, that its items changed since the manifest was signed. 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) SearchCargoCrateSummaries ¶ added in v0.5.0
func (p *PostgresDB) SearchCargoCrateSummaries(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrateSummary, int, error)
func (*PostgresDB) SearchCargoCrates ¶
func (p *PostgresDB) SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)
func (*PostgresDB) SearchComponents ¶ added in v0.6.0
func (p *PostgresDB) SearchComponents(ctx context.Context, repoID string, opts ComponentListOptions) ([]*models.Component, int, error)
SearchComponents is ListComponentsByRepo with the extra filters and the ordering of ComponentListOptions.
func (*PostgresDB) SearchNuGetPackages ¶
func (p *PostgresDB) SearchNuGetPackages(ctx context.Context, repoID, query string, skip, take int) ([]*models.NuGetPackage, int, error)
SearchNuGetPackages pages over matching packages: skip/take count packages, the total is the number of matching packages, and every live version of each package on the page is returned (grouped by package id, oldest first).
func (*PostgresDB) SearchRubyGems ¶
func (*PostgresDB) SecurityFindingsSummary ¶ added in v0.11.0
func (p *PostgresDB) SecurityFindingsSummary(ctx context.Context, f models.FindingFilter) (*models.FindingsSummary, error)
SecurityFindingsSummary counts the findings of the filter's scope per type and how many of its repositories were scanned.
func (*PostgresDB) SecurityHealthStats ¶ added in v0.11.0
func (p *PostgresDB) SecurityHealthStats(ctx context.Context) (*models.SecurityHealthStats, error)
SecurityHealthStats returns the instance-wide scan queue and coverage numbers.
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) SetBlobDeletionGrace ¶ added in v0.7.0
func (p *PostgresDB) SetBlobDeletionGrace(d time.Duration)
SetBlobDeletionGrace sets how long the bytes of a deleted blob (or of a tier copy a placement flip retired) are kept before the sweeper may remove them. Zero means as soon as no running backup can still need them.
func (*PostgresDB) SetBlobReplicationLastError ¶ added in v0.9.0
func (p *PostgresDB) SetBlobReplicationLastError(ctx context.Context, message string) error
SetBlobReplicationLastError records the most recent failure.
func (*PostgresDB) SetConanPackageDigests ¶ added in v0.8.0
func (p *PostgresDB) SetConanPackageDigests(ctx context.Context, id, md5, sha1 string) error
SetConanPackageDigests records the MD5 and SHA-1 of a file stored without them.
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) SetGlobalGPGKey ¶ added in v0.8.0
func (p *PostgresDB) SetGlobalGPGKey(ctx context.Context, id string) error
SetGlobalGPGKey makes id the one globally active key; ErrGPGKeyNotFound when absent.
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) SetNuGetDependencyGroups ¶ added in v0.6.0
func (p *PostgresDB) SetNuGetDependencyGroups(ctx context.Context, repoID, packageID, version string, groups []byte) error
SetNuGetDependencyGroups records the dependency groups of a package that has none stored yet. A stored value is never overwritten and updated_at is not touched.
func (*PostgresDB) SetPresignedUploadMultipartID ¶ added in v0.8.0
func (p *PostgresDB) SetPresignedUploadMultipartID(ctx context.Context, id, multipartID string) error
SetPresignedUploadMultipartID records the backend handle of the upload's open multipart upload.
func (*PostgresDB) SetProjectGroup ¶ added in v0.6.0
func (p *PostgresDB) SetProjectGroup(ctx context.Context, projectID, groupID, role string, createdBy *string) error
SetProjectGroup attaches the group to the project with role, or changes the role of an existing attachment.
func (*PostgresDB) SetProjectQuota ¶ added in v0.6.0
func (p *PostgresDB) SetProjectQuota(ctx context.Context, projectID string, maxSizeBytes, maxArtifactCount int64, warnThresholdPercent int) (*models.ProjectQuota, error)
SetProjectQuota stores the project's storage ceiling (0 = unlimited) and returns it. Enabling a limit initialises the project counters from the repository counters in the same transaction; disabling it zeroes them (they are only maintained while a limit is set).
func (*PostgresDB) SetRepositoryAttestationAttach ¶ added in v0.8.0
func (p *PostgresDB) SetRepositoryAttestationAttach(ctx context.Context, repoID string, enabled bool) error
SetRepositoryAttestationAttach stores the repository's attach switch.
func (*PostgresDB) SetRepositoryGPGKey ¶ added in v0.8.0
func (p *PostgresDB) SetRepositoryGPGKey(ctx context.Context, repoID, keyID, assignedBy string) error
SetRepositoryGPGKey makes keyID the signing key of one repository.
func (*PostgresDB) SetSessionSSO ¶ added in v0.8.0
func (p *PostgresDB) SetSessionSSO(ctx context.Context, sessionID, providerSlug, encryptedIDToken string) error
func (*PostgresDB) SetSystemSetting ¶
func (p *PostgresDB) SetSystemSetting(ctx context.Context, key, value string) error
SetSystemSetting sets or updates a system setting.
func (*PostgresDB) SetTrashRetentionDays ¶ added in v0.5.0
func (p *PostgresDB) SetTrashRetentionDays(days int)
SetTrashRetentionDays sets the server-wide default retention, in days, for repositories whose trash_retention_days is NULL.
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) StartReplicationVerify ¶ added in v0.9.0
func (p *PostgresDB) StartReplicationVerify(ctx context.Context, run json.RawMessage) (bool, error)
StartReplicationVerify begins a pass.
func (*PostgresDB) StorageBackendBusyReason ¶ added in v0.7.0
func (p *PostgresDB) StorageBackendBusyReason(ctx context.Context, backendID string) (string, error)
StorageBackendBusyReason reports why a backend's kind or config must not change (or the backend not be deleted): it holds blobs, is served by a tier or is named by a move journal row. "" means it is idle.
func (*PostgresDB) StorageTierUsage ¶ added in v0.7.0
StorageTierUsage returns blob counts and bytes per placement ("" = primary store).
func (*PostgresDB) SyncSSOGroups ¶
func (*PostgresDB) TouchBlobAccess ¶ added in v0.7.0
func (p *PostgresDB) TouchBlobAccess(ctx context.Context, accessed map[string]time.Time, resolution time.Duration) (int64, error)
TouchBlobAccess raises blobs.last_accessed_at for the given blobs in one statement. A blob whose recorded access is already within resolution of the new time is left alone, so repeated downloads of a hot blob cost no write. The exception is a blob whose recorded access is not newer than its last tier change: its first read on the new tier is always written, or promote-on-read would miss it for up to resolution after a demotion.
Rows are locked in sha256 order (FOR UPDATE under ORDER BY) so two replicas flushing overlapping sets cannot deadlock each other. Every write here is a non-HOT update (last_accessed_at is in the promotion index predicate), which the access resolution bounds to one per blob per resolution window.
func (*PostgresDB) TouchDockerBlob ¶ added in v0.4.0
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) TrashRepository ¶ added in v0.5.0
TrashRepository implements TrashStore.
func (*PostgresDB) TrashRows ¶ added in v0.5.0
func (p *PostgresDB) TrashRows(ctx context.Context, repoID string, kind models.TrashKind, ids []string, deletedBy string) (bool, error)
TrashRows implements TrashStore.
func (*PostgresDB) TrashedRepositoryByName ¶ added in v0.5.0
func (p *PostgresDB) TrashedRepositoryByName(ctx context.Context, name string) (*models.TrashItem, error)
TrashedRepositoryByName returns the repository in the trash that holds name (its name stays reserved until it is purged or restored), ErrTrashNotFound when no trashed repository has it. It is not part of TrashStore: only the repository-create conflict message needs it.
func (*PostgresDB) TryGomodRepairLock ¶ added in v0.5.0
func (p *PostgresDB) TryGomodRepairLock(ctx context.Context) (func(), bool, error)
TryGomodRepairLock takes the repair's session advisory lock on a pinned connection. ok is false when another replica holds it. release must be called when ok is true; it unlocks and returns the connection to the pool.
func (*PostgresDB) UnreferencedBlobKeys ¶ added in v0.5.0
UnreferencedBlobKeys returns the subset of ids (blob store keys) that no blobs row carries as its sha256.
func (*PostgresDB) UpdateBackupJob ¶
UpdateBackupJob updates an existing backup job.
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, oldOffset, newOffset int64) (bool, error)
UpdateDockerUploadOffset moves the session's offset from oldOffset to newOffset and reports whether it did: false means the offset no longer equals oldOffset (another request advanced or completed the session).
func (*PostgresDB) UpdateGroup ¶
func (*PostgresDB) UpdateLicensePolicy ¶
func (p *PostgresDB) UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
UpdateLicensePolicy updates a license policy.
func (*PostgresDB) UpdateNPMPackageLatestVersion ¶
func (p *PostgresDB) UpdateNPMPackageLatestVersion(ctx context.Context, packageID, latestVersion string) error
func (*PostgresDB) UpdateNPMVersionManifest ¶ added in v0.5.0
func (*PostgresDB) UpdatePermissionTarget ¶
func (p *PostgresDB) UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error
func (*PostgresDB) UpdateProject ¶ added in v0.6.0
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) UpdateRepositoryAndMembers ¶ added in v0.5.0
func (p *PostgresDB) UpdateRepositoryAndMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
UpdateRepositoryAndMembers updates the repository row and replaces its group members in one transaction, so a failure of either leaves neither applied.
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. When the extra data carries sizes (sizes_parsed, see pkgrpm.Package.MarshalExtra) the installed_size and archive_size columns are corrected from it too: rows stored before the header size tags were read properly hold 0.
func (*PostgresDB) UpdateSSOProvider ¶
func (p *PostgresDB) UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
func (*PostgresDB) UpdateSessionLastSeen ¶
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) UpdateStoragePolicy ¶ added in v0.7.0
func (p *PostgresDB) UpdateStoragePolicy(ctx context.Context, pol *models.StoragePolicy) error
UpdateStoragePolicy overwrites every field of the policy.
func (*PostgresDB) UpdateStorageQuota ¶
func (p *PostgresDB) UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
UpdateStorageQuota updates a storage quota.
func (*PostgresDB) UpdateStorageTier ¶ added in v0.7.0
func (p *PostgresDB) UpdateStorageTier(ctx context.Context, t *models.StorageTier) error
UpdateStorageTier updates a tier's name, rank and promote-on-read flag.
func (*PostgresDB) UpdateTokenLastUsed ¶
func (p *PostgresDB) UpdateTokenLastUsed(ctx context.Context, tokenID string) error
func (*PostgresDB) UpdateUser ¶
func (*PostgresDB) UpdateUserLastLogin ¶ added in v0.5.0
func (*PostgresDB) UpdateUserPassword ¶ added in v0.5.0
func (*PostgresDB) UpdateUserSSO ¶
func (*PostgresDB) UpdateUserSSOProfile ¶ added in v0.6.0
func (*PostgresDB) UpdateVulnScanResult ¶
func (p *PostgresDB) UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
UpdateVulnScanResult updates a vulnerability scan result.
func (*PostgresDB) UpdateWebhook ¶
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; ArtifactName/ArtifactVersion live on ai_results (artifact_refs only tracks repository_id/artifact_path/format). analysis.Status's "processing" value is mapped onto scan_jobs' CHECK-constrained "running" (see aiStatusToJob/FromJob).
Only a "completed" analysis overwrites the result columns (summary, tags, license, security notes, model, token counts). A "processing", "pending" or "failed" upsert keeps what the last completed run stored, so a re-trigger or a failed re-analysis never wipes a good result; the status and error live on scan_jobs and always follow the latest upsert.
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) UpsertDeclarativeObjects ¶ added in v0.8.1
func (p *PostgresDB) UpsertDeclarativeObjects(ctx context.Context, items []models.DeclarativeObject) ([]models.DeclarativeObject, error)
UpsertDeclarativeObjects stores the markers by (kind, name) in one transaction and returns them as stored.
func (*PostgresDB) UpsertDependencyTrackPush ¶ added in v0.8.0
func (p *PostgresDB) UpsertDependencyTrackPush(ctx context.Context, s *models.DependencyTrackPush) error
UpsertDependencyTrackPush records the state of an artifact's push and fills the stored row back into s.
func (*PostgresDB) UpsertDockerTag ¶
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) UpsertRepositoryDependencyTrack ¶ added in v0.8.0
func (p *PostgresDB) UpsertRepositoryDependencyTrack(ctx context.Context, c *models.RepositoryDependencyTrack) error
UpsertRepositoryDependencyTrack stores the override and fills the stored row back into c.
func (*PostgresDB) UpsertVEXStatement ¶ added in v0.7.0
func (p *PostgresDB) UpsertVEXStatement(ctx context.Context, s *models.VEXStatement) error
UpsertVEXStatement records (or replaces) the decision for (RepositoryID, ArtifactID, VulnID) and fills the stored row back into s.
func (*PostgresDB) VulnScanOverviewSummary ¶ added in v0.7.0
func (p *PostgresDB) VulnScanOverviewSummary(ctx context.Context, repoName string) (*models.VulnScanSummary, error)
VulnScanOverviewSummary counts the overview's scans in one pass, all of them or those of one repository.
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 (*PostgresDB) YankRubyGem ¶
type PostgresTx ¶
type PostgresTx struct {
// contains filtered or unexported fields
}
PostgresTx implements the Transaction interface for PostgreSQL.
func (*PostgresTx) ExecContext ¶
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 ¶
QueryRowContext executes a query that returns a single row.
func (*PostgresTx) Rollback ¶
func (t *PostgresTx) Rollback() error
Rollback rolls back the transaction.
type ProjectRoleGuard ¶ added in v0.6.0
ProjectRoleGuard decides a member or group change while the project row is locked. current is the target's role before the change ("" when the target has none); a non-nil error vetoes the change and is returned unchanged.
type ProjectTokenSpec ¶ added in v0.6.0
type ProjectTokenSpec struct {
ProjectID string
// ProjectSlug seeds the service user's name.
ProjectSlug string
Name string
// Role is the token's project role (viewer or developer).
Role string
CreatedBy string
TokenHash string
ExpiresAt *time.Time
// MaxActive caps the active (not revoked) tokens of the project.
MaxActive int
}
ProjectTokenSpec describes a project token to mint.
type SnapshotReader ¶ added in v0.7.0
type SnapshotReader interface {
GetComponentsByRepo(ctx context.Context, repoID string) ([]models.Component, error)
GetDebianArchitecturesByDist(ctx context.Context, distID string) ([]models.DebianArchitecture, error)
GetDebianComponentsByDist(ctx context.Context, distID string) ([]models.DebianComponent, error)
GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)
GetDebianPackagesByDistComp(ctx context.Context, repoID string, dist string, comp string, arch string) ([]models.Component, error)
GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)
GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
ListAIAnalyses(ctx context.Context, repoID string, status string, licenseReviewOnly bool, limit, offset int) ([]*models.AIAnalysis, int, error)
ListAllCondaPackages(ctx context.Context, repoID string) ([]*models.CondaPackage, error)
ListAllNPMPackages(ctx context.Context, repoID string) ([]*models.NPMPackage, error)
ListAllProjects(ctx context.Context) ([]*models.Project, error)
ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
ListAllTokens(ctx context.Context, page, perPage int) ([]*models.Token, int, error)
ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)
ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)
ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)
ListConanPackages(ctx context.Context, repoID string) ([]*models.ConanPackage, error)
ListDockerBlobs(ctx context.Context, repoID string) ([]*models.DockerBlob, error)
ListDockerManifestsByRepo(ctx context.Context, repoID string) ([]*models.DockerManifest, error)
ListDockerTagsByRepo(ctx context.Context, repoID string, limit int) ([]*models.DockerTag, error)
ListGoModulesByRepo(ctx context.Context, repoID string) ([]*models.GoModule, error)
ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
ListGroups(ctx context.Context) ([]*models.Group, error)
ListHelmCharts(ctx context.Context, repoID string) ([]*models.HelmChart, error)
ListIvyArtifacts(ctx context.Context, repoID string) ([]*models.IvyArtifact, error)
ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)
ListMavenArtifactsByRepo(ctx context.Context, repoID string) ([]*models.MavenArtifact, error)
ListNPMVersionsByRepo(ctx context.Context, repoID string) ([]*models.NPMVersion, error)
ListNuGetPackages(ctx context.Context, repoID string) ([]*models.NuGetPackage, error)
ListPermissionAssignments(ctx context.Context) ([]*models.PermissionAssignment, error)
ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)
ListProjectCleanupPolicies(ctx context.Context, projectID string) ([]*models.CleanupPolicy, error)
ListProjectGroups(ctx context.Context, projectID string) ([]*models.ProjectGroup, error)
ListProjectMembers(ctx context.Context, projectID string) ([]*models.ProjectMember, error)
ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)
ListPyPIPackages(ctx context.Context, repoID string) ([]*models.PyPIPackage, error)
ListRawArtifacts(ctx context.Context, repoID, prefix string) ([]*models.RawArtifact, error)
ListReleaseBundles(ctx context.Context, nameFilter, stateFilter string, page, limit int) ([]*models.ReleaseBundle, int, error)
ListRepositories(ctx context.Context, page, limit int, formatFilter string) ([]*models.Repository, error)
ListRubyGems(ctx context.Context, repoID string) ([]*models.RubyGem, error)
ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)
ListVEXStatements(ctx context.Context, repoID, artifactID string) ([]*models.VEXStatement, error)
ListSBTArtifacts(ctx context.Context, repoID string) ([]*models.SBTArtifact, error)
ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)
ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)
ListStorageQuotas(ctx context.Context) ([]*models.StorageQuota, error)
ListUserGroupMemberships(ctx context.Context) ([]*models.UserGroup, error)
ListUsers(ctx context.Context, page, perPage int) ([]*models.User, int, error)
ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)
ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error) // repoID="" = global
SearchCargoCrates(ctx context.Context, repoID, query string, limit int) ([]*models.CargoCrate, error)
// ListBlobsAfter returns up to limit stored objects with sha256 > after, in
// sha256 order: blobs rows plus the generated metadata and deltas that
// have no blobs row.
ListBlobsAfter(ctx context.Context, after string, limit int) ([]BlobRow, error)
// CountBlobs returns the number of objects ListBlobsAfter pages through.
CountBlobs(ctx context.Context) (int64, error)
// Release ends the snapshot and removes its lease. It is idempotent.
Release()
}
SnapshotReader reads the database as of one instant: every call sees the same committed state, however long the backup takes and whatever is written meanwhile. It is read-only by construction (only read methods are listed, and the underlying transactions are READ ONLY).
A snapshot also holds a lease: while it is open, the sweeper deletes no blob bytes the snapshot can still see (a blob deleted, or a tier copy retired, after the snapshot was taken stays readable). Release ends both; a crashed holder's lease expires on its own.
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.
type TrashStore ¶ added in v0.5.0
type TrashStore interface {
// TrashRows soft-deletes the given rows of repoID (stamps deleted_at and
// deleted_by) and returns true. It returns false without touching anything
// when the repository's retention is 0: the caller then hard-deletes as
// before. ErrTrashNotFound means none of the rows is live in repoID.
TrashRows(ctx context.Context, repoID string, kind models.TrashKind, ids []string, deletedBy string) (bool, error)
// TrashRepository soft-deletes a repository (contents stay in place, hidden
// with it). It returns false without touching anything when retention is 0.
TrashRepository(ctx context.Context, id, deletedBy string) (bool, error)
// ListTrash lists trashed items (newest first) and the total count.
ListTrash(ctx context.Context, f models.TrashFilter) ([]*models.TrashItem, int, error)
// GetTrashItem returns one trashed item, ErrTrashNotFound when absent.
GetTrashItem(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
// RestoreTrash brings an item (or a repository) back. ErrTrashNotFound,
// ErrTrashConflict (unique key taken meanwhile) and ErrTrashRepoTrashed
// are the expected failures.
RestoreTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashItem, error)
// PurgeTrash permanently removes a trashed item (or repository, cascading
// its contents) and reports what the caller must clean up: blobs to free via
// storage.SafeDeleteBlob and quota to release. A repository's blobs are not
// listed (they can be numerous); the caller collects orphans afterwards.
// A foreign-key violation (IsForeignKeyViolation) means the repository is
// still referenced, e.g. by a release bundle.
PurgeTrash(ctx context.Context, kind models.TrashKind, id string) (*models.TrashPurgeResult, error)
// RegenKeys returns what the metadata workers key a refresh by for an item:
// (group_id, artifact_id) for a Maven artifact, (package_id, "") for an npm
// version and ("", "") for every other kind (deb/rpm refresh per repository).
RegenKeys(ctx context.Context, kind models.TrashKind, id string) (string, string, error)
// ListExpiredTrash returns up to limit items whose retention window has
// passed (items of repositories that are themselves in the trash are
// left to the repository's own purge).
ListExpiredTrash(ctx context.Context, limit int) ([]models.TrashRef, error)
}
TrashStore is the storage side of soft delete (internal/trash, the trash API and the purge worker). PostgresDB implements it; handlers treat a database that does not (test fakes) as "soft delete unavailable" and hard-delete.
Retention is resolved per repository: repositories.trash_retention_days, or the server default (SetTrashRetentionDays) when NULL. 0 means no trash.
Source Files
¶
- auth_cache.go
- blobhash.go
- catalog_branches.go
- catalog_sql.go
- docker.go
- docker_catalog.go
- docker_gc.go
- gomod_repair.go
- interfaces.go
- migrate.go
- migrate_split.go
- postgres.go
- postgres_apibundlesscans.go
- postgres_apirepos.go
- postgres_audit_retention.go
- postgres_auth.go
- postgres_authsec.go
- postgres_backup_lists.go
- postgres_blob_deletions.go
- postgres_blobs.go
- postgres_bundles.go
- postgres_catalog.go
- postgres_conn.go
- postgres_deb.go
- postgres_declarative.go
- postgres_dtrack.go
- postgres_gpg.go
- postgres_groupmeta.go
- postgres_licensequarantine.go
- postgres_maven.go
- postgres_meta_stamps.go
- postgres_npm.go
- postgres_platform.go
- postgres_presigned.go
- postgres_project_quota.go
- postgres_project_tokens.go
- postgres_projects.go
- postgres_quarantine.go
- postgres_quota.go
- postgres_replication.go
- postgres_rpm.go
- postgres_scanrows.go
- postgres_security.go
- postgres_snapshot.go
- postgres_sso.go
- postgres_tiering.go
- postgres_tokens.go
- postgres_vex.go
- postgres_vulnoverview.go
- postgres_wait.go
- replication.go
- snapshot.go
- trash.go
- trash_kinds.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package databasetest provides test doubles for the database.Database interface: embed BaseMockDB in a test mock and override only the methods you need.
|
Package databasetest provides test doubles for the database.Database interface: embed BaseMockDB in a test mock and override only the methods you need. |