Documentation
¶
Overview ¶
Package store owns SQLite access and schema migrations.
Index ¶
- Constants
- Variables
- func CombinedStatus(statuses []CommitStatus) string
- func HashToken(token string) string
- func NewToken() (token, hash string, err error)
- type APIToken
- type AccessEntry
- type AuditEntry
- type Build
- type CommitStatus
- type Counts
- type DashboardItem
- type Delivery
- type DeliveryStatus
- type DiffComment
- type Email
- type FeedEvent
- type Issue
- type IssueComment
- type MR
- type MRReview
- type Milestone
- type Mirror
- type Org
- type OrgMember
- type PGPKey
- type PageDomain
- type Profile
- type QueuedMail
- type Release
- type ReleaseAsset
- type Repo
- type RepoSettings
- type SSHKey
- type Schedule
- type SigDB
- type Store
- func (s *Store) APITokenUser(tokenHash string) (User, string, error)
- func (s *Store) AccessRole(repoID, userID int64) (string, error)
- func (s *Store) ActivityByDay(userID int64, sinceDay string) (map[string]int, error)
- func (s *Store) AddDiffComment(mrID, authorID int64, headSHA, path, side string, line int64, body string, ...) (int64, error)
- func (s *Store) AddEmail(userID int64, address, verifiedBy string, primary bool) error
- func (s *Store) AddIssueComment(issueID, authorID int64, body string) error
- func (s *Store) AddIssueSystemComment(issueID, actorID int64, body string) error
- func (s *Store) AddMRComment(mrID, authorID int64, body string) error
- func (s *Store) AddMRReview(mrID, reviewerID int64, verdict, headSHA string) error
- func (s *Store) AddMRSystemComment(mrID, actorID int64, body string) error
- func (s *Store) AddMirror(repoID int64, direction, url, username, token string) (int64, error)
- func (s *Store) AddPGPKey(userID int64, fingerprint, armored, uidsJSON string, ...) error
- func (s *Store) AddPageDomain(domain string, repoID, userID int64, token string, ttlSeconds int) error
- func (s *Store) AddReleaseAsset(releaseID int64, name string, size int64, sha256 string) error
- func (s *Store) AddSSHKey(userID int64, fingerprint, algo string, blob []byte, scope string) error
- func (s *Store) AddTeamMember(teamID, userID int64) error
- func (s *Store) AddTopic(repoID int64, topic string) error
- func (s *Store) AddWebhook(repoID int64, url, secret, events string) (int64, error)
- func (s *Store) AppendBuildLog(id int64, chunk []byte) error
- func (s *Store) AssignedIssues(userID int64) ([]DashboardItem, error)
- func (s *Store) Audit(actorID int64, action string, data map[string]any)
- func (s *Store) AuditEntries(limit int) ([]AuditEntry, error)
- func (s *Store) BuildByID(id int64) (Build, error)
- func (s *Store) BuildByNumber(repoID, number int64) (Build, error)
- func (s *Store) BuildLog(id int64) ([]byte, error)
- func (s *Store) BuildSecrets(repoID int64) (map[string]string, error)
- func (s *Store) CachedSignature(repoID int64, sha string, epoch int64) (sig.Result, bool, error)
- func (s *Store) ClaimBuild() (Build, bool, error)
- func (s *Store) ClearPending(userID int64) error
- func (s *Store) Close() error
- func (s *Store) CombinedStatusFor(repoID int64, shas []string) (map[string]string, error)
- func (s *Store) ConsumeEmailToken(userID int64, tokenHash string) (string, error)
- func (s *Store) ConsumeInvite(codeHash string) (string, error)
- func (s *Store) ConsumeLoginToken(hash string) (int64, error)
- func (s *Store) CreateAPIToken(userID int64, name, tokenHash, scope string, expires *time.Time) error
- func (s *Store) CreateBuild(repoID int64, job, sha, ref, stepsJSON string) (int64, error)
- func (s *Store) CreateEmailToken(userID int64, address, tokenHash string, ttl time.Duration) error
- func (s *Store) CreateInvite(codeHash, email string) error
- func (s *Store) CreateIssue(repoID, authorID int64, title, body string) (int64, error)
- func (s *Store) CreateLoginToken(userID int64, hash string, ttl time.Duration) error
- func (s *Store) CreateMR(repoID, authorID, sourceRepoID int64, ...) (int64, error)
- func (s *Store) CreateMilestone(repoID int64, title, description, due string) (int64, error)
- func (s *Store) CreateOrg(name string, creatorID int64) (int64, error)
- func (s *Store) CreateRegisteredUser(username string, pending bool) (int64, error)
- func (s *Store) CreateRelease(repoID int64, tag, title, notes string, authorID int64) (int64, error)
- func (s *Store) CreateRepo(ownerKind string, ownerID int64, name, visibility string) (int64, error)
- func (s *Store) CreateTeam(orgID int64, name string) (int64, error)
- func (s *Store) CreateUser(username string, isAdmin bool) (int64, error)
- func (s *Store) CreateWebSession(hash string, userID int64, ttl time.Duration) error
- func (s *Store) DashboardIssues(userID int64) ([]DashboardItem, error)
- func (s *Store) DashboardMRs(userID int64) ([]DashboardItem, error)
- func (s *Store) DeleteOrg(orgID int64) error
- func (s *Store) DeleteRelease(id int64) error
- func (s *Store) DeleteRepo(repoID int64) error
- func (s *Store) DeleteTeam(teamID int64) error
- func (s *Store) DeleteUser(id int64) error
- func (s *Store) DeleteWebSession(hash string) error
- func (s *Store) DiffCommentAuthor(mrID, id int64) (int64, error)
- func (s *Store) DueDeliveries(limit int) ([]Delivery, error)
- func (s *Store) DueMail(limit int) ([]QueuedMail, error)
- func (s *Store) DueMirrors(intervalSeconds int) ([]Mirror, error)
- func (s *Store) DueSchedules(nowISO string) ([]Schedule, error)
- func (s *Store) EmailInUse(address string) (bool, error)
- func (s *Store) EnqueueMail(recipient, subject, body string) error
- func (s *Store) FinishBuild(id int64, status string) error
- func (s *Store) GrantAccess(repoID, userID int64, role string) error
- func (s *Store) GrantTeamRepo(teamID, repoID int64, role string) error
- func (s *Store) ImportMarker(repoID int64, key string) (string, bool, error)
- func (s *Store) InstanceCounts() (Counts, error)
- func (s *Store) IsPinned(userID, repoID int64) bool
- func (s *Store) IssueByNumber(repoID, number int64) (Issue, error)
- func (s *Store) IssueParticipants(issueID int64) ([]int64, error)
- func (s *Store) KeyEpoch() (int64, error)
- func (s *Store) LFSSecret(gen func() string) (string, error)
- func (s *Store) LabelColors(repoID int64) (map[string]string, error)
- func (s *Store) LatestBuild(repoID int64, job string) (Build, error)
- func (s *Store) ListAPITokens(userID int64) ([]APIToken, error)
- func (s *Store) ListAccess(repoID int64) ([]AccessEntry, error)
- func (s *Store) ListAllRepos() ([]Repo, error)
- func (s *Store) ListBuildSecretNames(repoID int64) ([]string, error)
- func (s *Store) ListBuilds(repoID int64, limit int) ([]Build, error)
- func (s *Store) ListCommitStatuses(repoID int64, sha string) ([]CommitStatus, error)
- func (s *Store) ListDeliveries(repoID int64, limit int) ([]DeliveryStatus, error)
- func (s *Store) ListDeployKeys(repoID int64) ([]SSHKey, error)
- func (s *Store) ListDiffComments(mrID int64) ([]DiffComment, error)
- func (s *Store) ListEmails(userID int64) ([]Email, error)
- func (s *Store) ListIssueComments(issueID int64) ([]IssueComment, error)
- func (s *Store) ListIssueLabels(repoID int64) (map[int64][]string, error)
- func (s *Store) ListIssues(repoID int64, state string) ([]Issue, error)
- func (s *Store) ListMRComments(mrID int64) ([]IssueComment, error)
- func (s *Store) ListMRReviews(mrID int64) ([]MRReview, error)
- func (s *Store) ListMRs(repoID int64, state string) ([]MR, error)
- func (s *Store) ListMilestones(repoID int64, state string) ([]Milestone, error)
- func (s *Store) ListMirrors(repoID int64) ([]Mirror, error)
- func (s *Store) ListOrgsForUser(userID int64) ([]OrgMember, error)
- func (s *Store) ListPGPKeys(userID int64) ([]PGPKey, error)
- func (s *Store) ListPageDomains(repoID int64) ([]PageDomain, error)
- func (s *Store) ListPublicRepos() ([]Repo, error)
- func (s *Store) ListReleases(repoID int64) ([]Release, error)
- func (s *Store) ListReposForOwner(ownerKind string, ownerID int64) ([]Repo, error)
- func (s *Store) ListReposForUser(userID int64) ([]Repo, error)
- func (s *Store) ListSSHKeys(userID int64) ([]SSHKey, error)
- func (s *Store) ListTeams(orgID int64) ([]Team, error)
- func (s *Store) ListTopics(repoID int64) ([]string, error)
- func (s *Store) ListWebhooks(repoID int64) ([]Webhook, error)
- func (s *Store) MRByNumber(repoID, number int64) (MR, error)
- func (s *Store) MRParticipants(mrID int64) ([]int64, error)
- func (s *Store) MarkAttemptFailed(id int64, status int, errMsg string, nextAt *time.Time) error
- func (s *Store) MarkDelivered(id int64, status int) error
- func (s *Store) MarkMailFailed(id int64, errMsg string, nextAt *time.Time) error
- func (s *Store) MarkMailSent(id int64) error
- func (s *Store) MarkMerged(mrID int64, baseSHA string) error
- func (s *Store) MarkMirrorsDirty(repoID int64, direction string) error
- func (s *Store) MarkSourceGoneForRepo(sourceRepoID int64) error
- func (s *Store) MigrateCommitRefComments() (int, error)
- func (s *Store) MigrateTo(target int) error
- func (s *Store) MigrateUp() error
- func (s *Store) MilestoneByTitle(repoID int64, title string) (Milestone, error)
- func (s *Store) OpenCounts(repoID int64) (issues, mrs int)
- func (s *Store) OpenMRsBySource(sourceRepoID int64, sourceRef string) ([]MR, error)
- func (s *Store) OrgActivityByDay(orgID int64, sinceDay string) (map[string]int, error)
- func (s *Store) OrgByName(name string) (Org, error)
- func (s *Store) OrgMembers(orgID int64) ([]OrgMember, error)
- func (s *Store) OrgRole(orgID, userID int64) (string, error)
- func (s *Store) OwnerExists(name string) bool
- func (s *Store) OwnerProfile(kind string, id int64) (Profile, error)
- func (s *Store) PageDomainClaim(domain string, repoID int64) (PageDomain, error)
- func (s *Store) PageDomainExpired(d PageDomain, ttlSeconds int) bool
- func (s *Store) PageDomainRepo(domain string) (Repo, error)
- func (s *Store) PinRepo(userID, repoID int64) error
- func (s *Store) PinnedRepos(userID int64) ([]Repo, error)
- func (s *Store) PrimaryVerifiedEmail(userID int64) (string, error)
- func (s *Store) PullMirrored(repoID int64) (bool, error)
- func (s *Store) RecentEvents(userID int64, limit int) ([]FeedEvent, error)
- func (s *Store) RecordCommitActivity(repoID int64, sha string, userID int64, day string) bool
- func (s *Store) RecordEvent(repoID, actorID int64, kind, dataJSON string) error
- func (s *Store) RedeemInvite(codeHash, username, keyFP, keyAlgo string, keyBlob []byte) (string, error)
- func (s *Store) Redeliver(repoID, deliveryID int64) error
- func (s *Store) RegisterOpen(username, email, keyFP, keyAlgo string, keyBlob []byte) (int64, error)
- func (s *Store) ReleaseByTag(repoID int64, tag string) (Release, error)
- func (s *Store) RemoveBuildSecret(repoID int64, name string) error
- func (s *Store) RemoveDeployKey(repoID int64, fingerprint string) error
- func (s *Store) RemoveMirror(repoID, id int64) error
- func (s *Store) RemoveOrgMember(orgID, userID int64) error
- func (s *Store) RemovePGPKey(userID int64, fingerprint string) error
- func (s *Store) RemovePageDomain(domain string, repoID int64) error
- func (s *Store) RemoveReleaseAsset(releaseID int64, name string) error
- func (s *Store) RemoveSSHKey(userID int64, fingerprint string) error
- func (s *Store) RemoveSchedule(repoID int64, job string) error
- func (s *Store) RemoveTeamMember(teamID, userID int64) error
- func (s *Store) RemoveTopic(repoID int64, topic string) error
- func (s *Store) RemoveWebhook(repoID, hookID int64) error
- func (s *Store) RenameOrg(orgID int64, newName string) error
- func (s *Store) RepoByID(id int64) (Repo, error)
- func (s *Store) RepoByPath(path string) (Repo, error)
- func (s *Store) RepoNotifyTargets(repo Repo) ([]int64, error)
- func (s *Store) ReviewQueue(userID int64) ([]DashboardItem, error)
- func (s *Store) RevokeAPIToken(userID int64, name string) error
- func (s *Store) RevokeAccess(repoID, userID int64) error
- func (s *Store) RevokeTeamRepo(teamID, repoID int64) error
- func (s *Store) SSHKeyByFingerprint(fingerprint string) (SSHKey, error)
- func (s *Store) SSHKeyByID(id int64) (SSHKey, error)
- func (s *Store) SetBuildSecret(repoID int64, name, value string) error
- func (s *Store) SetCommitStatus(repoID int64, sha, context, state, description, targetURL string, ...) error
- func (s *Store) SetForkOf(repoID, parentID int64) error
- func (s *Store) SetImportMarker(repoID int64, key, value string) error
- func (s *Store) SetIssueAssignee(issueID, userID int64, add bool) error
- func (s *Store) SetIssueLabel(repoID, issueID int64, name string, add bool) error
- func (s *Store) SetIssueMilestone(issueID, milestoneID int64) error
- func (s *Store) SetIssueState(issueID int64, state string) error
- func (s *Store) SetMRMilestone(mrID, milestoneID int64) error
- func (s *Store) SetMRState(mrID int64, state string) error
- func (s *Store) SetMilestoneState(id int64, state string) error
- func (s *Store) SetMirrorResult(id int64, syncErr string) error
- func (s *Store) SetOrgMember(orgID, userID int64, role string) error
- func (s *Store) SetOrgMembersRole(orgID int64, role string) error
- func (s *Store) SetOwnerProfile(kind string, id int64, p Profile) error
- func (s *Store) SetRepoSettings(repoID int64, settings RepoSettings) error
- func (s *Store) SetRepoVisibility(repoID int64, visibility string) error
- func (s *Store) SetScheduleNext(repoID int64, job, nextRun string) error
- func (s *Store) SetThreadResolved(mrID, rootID, byUser int64, resolved bool) error
- func (s *Store) SetUserDisabled(userID int64, disabled bool) error
- func (s *Store) StoreSignature(repoID int64, sha string, r sig.Result, epoch int64) error
- func (s *Store) SyncSchedules(repoID int64, entries []Schedule) error
- func (s *Store) TeamByName(orgID int64, name string) (Team, error)
- func (s *Store) TeamGrants(teamID int64) ([]TeamGrant, error)
- func (s *Store) TeamMembers(teamID int64) ([]string, error)
- func (s *Store) TouchSSHKey(id int64) error
- func (s *Store) TransferRepo(repoID int64, newKind string, newOwnerID int64) error
- func (s *Store) TryRecordCommitRef(issueID int64, sha string) (bool, error)
- func (s *Store) UnpinRepo(userID, repoID int64) error
- func (s *Store) UnresolvedThreadCount(mrID int64) (int, error)
- func (s *Store) UpdateDefaultBranch(repoID int64, branch string) error
- func (s *Store) UpdateIssueText(issueID int64, title, body *string) error
- func (s *Store) UpdateMRHead(mrID int64, headSHA string) error
- func (s *Store) UpdateMRText(mrID int64, title, body *string) error
- func (s *Store) UpdateRelease(repoID int64, tag, title, notes string) error
- func (s *Store) UserByID(id int64) (User, error)
- func (s *Store) UserByUsername(name string) (User, error)
- func (s *Store) UserEmailAddresses(userID int64) ([]string, error)
- func (s *Store) UserIDByVerifiedEmail(address string) (int64, bool)
- func (s *Store) UsernameByVerifiedEmail(address string) (string, bool)
- func (s *Store) VerifyEmail(userID int64, address, by string) error
- func (s *Store) VerifyPageDomain(domain string, repoID int64) error
- func (s *Store) Version() (int, error)
- func (s *Store) WebSessionUser(hash string) (User, error)
- type Team
- type TeamGrant
- type User
- type Webhook
Constants ¶
const MaxBuildLog = 2 << 20
MaxBuildLog caps a build's stored log; appends past it are dropped.
Variables ¶
var ErrDuplicateKey = errors.New("that key is already registered to another account; remove it there first or use a different key")
ErrDuplicateKey carries the exact user-facing message from the spec. It deliberately does not name the owning account (enumeration oracle).
ErrExists marks unique-constraint refusals callers turn into messages.
Functions ¶
func CombinedStatus ¶ added in v0.2.0
func CombinedStatus(statuses []CommitStatus) string
Types ¶
type APIToken ¶
type AuditEntry ¶ added in v0.2.0
type Build ¶ added in v0.3.0
type Build struct {
ID int64
RepoID int64
Number int64
Job string
SHA string
Ref string
Steps string // JSON array of shell commands
Status string // pending|running|success|failure
CreatedAt string
StartedAt string
FinishedAt string
}
Build is one CI job execution for one commit.
type CommitStatus ¶ added in v0.2.0
type Counts ¶ added in v0.2.0
type DashboardItem ¶ added in v0.2.0
type DashboardItem struct {
RepoPath string
Number int64
Title string
Author string
State string
UpdatedAt string
}
DashboardItem is one open issue or MR row on the logged-in homepage.
type Delivery ¶
type DeliveryStatus ¶
type DiffComment ¶ added in v0.2.0
type Email ¶ added in v1.0.0
type Email struct {
Address string
Verified bool
VerifiedBy string // smtp | admin, empty when unverified
Primary bool
}
Email is one address on an account, with the state the signature rules and notification routing depend on.
type FeedEvent ¶ added in v0.5.0
FeedEvent is one line of the dashboard's activity feed.
type Issue ¶
type IssueComment ¶
type MR ¶
type MR struct {
ID int64
RepoID int64
Number int64
Author string
SourceRepoID int64 // 0 when the source repo is gone
SourcePath string // owner/name of source repo, "" when gone
SourceRef string
TargetRef string
Title string
Body string
State string // open | merged | closed | source_gone
Milestone string
HeadSHA string
MergedBase string // target tip at merge time; base for historical diffs
CreatedAt string
UpdatedAt string
}
type MRReview ¶
type Milestone ¶ added in v0.2.0
type Mirror ¶ added in v0.2.0
type Mirror struct {
ID int64
RepoID int64
Direction string // push | pull
URL string
Username string
Token string
Dirty bool
LastSync string
LastError string
}
Mirror propagates refs to (push) or from (pull) a foreign remote. The token is stored server-side — unlike import, mirroring is recurring — and must never be echoed back in listings.
type PGPKey ¶
type PageDomain ¶ added in v0.3.0
type PageDomain struct {
Domain string
RepoID int64
UserID int64
Token string
CreatedAt string
VerifiedAt string
}
PageDomain is one custom-domain claim. A claim starts pending — it holds the domain but serves nothing — and activates when the DNS challenge verifies. Pending claims expire so a squatted claim frees itself.
func (PageDomain) Verified ¶ added in v0.3.0
func (d PageDomain) Verified() bool
type Profile ¶
type Profile struct {
Description string `json:"description,omitempty"`
Website string `json:"website,omitempty"`
}
Profile is the presentational half of a user or org.
type QueuedMail ¶ added in v0.2.0
type Release ¶ added in v0.2.0
type ReleaseAsset ¶ added in v0.2.0
type Repo ¶
type RepoSettings ¶
type RepoSettings struct {
ProtectedBranches []string `json:"protected_branches,omitempty"`
RequireSignedCommits bool `json:"require_signed_commits,omitempty"`
RequireChecks bool `json:"require_checks,omitempty"`
RequireApprovals int `json:"require_approvals,omitempty"`
RequireResolved bool `json:"require_resolved,omitempty"`
GitDaemon bool `json:"git_daemon,omitempty"`
Archived bool `json:"archived,omitempty"`
Website string `json:"website,omitempty"`
}
type SSHKey ¶
type Schedule ¶ added in v0.3.0
Schedule is one repo job's cron entry.
type SigDB ¶
type SigDB struct{ *Store }
SigDB adapts Store to the verifier's interface and owns the epoch cache.
func (SigDB) PGPKeyByIssuer ¶
func (SigDB) SSHSignerByFingerprint ¶
type Store ¶
func Open ¶
Open opens (creating if needed) the database at path with WAL mode and foreign keys enforced. Use ":memory:" in tests.
func (*Store) APITokenUser ¶
APITokenUser resolves a presented token to its user and scope; expired and unknown tokens fail identically.
func (*Store) AccessRole ¶
AccessRole returns the user's effective role on the repo ("" if none): the strongest of any explicit grant, the role derived from org membership (org admin -> admin; plain member -> the org's members_role, 'write' by default so the pre-teams model is the degenerate case), and any team grants on the repo.
func (*Store) ActivityByDay ¶ added in v0.3.0
ActivityByDay aggregates a user's activity per day since the given day: commits landed on default branches plus everything the events table attributes to them (issues, MRs, comments, releases, pushes).
func (*Store) AddDiffComment ¶ added in v0.2.0
func (s *Store) AddDiffComment(mrID, authorID int64, headSHA, path, side string, line int64, body string, replyTo int64) (int64, error)
AddDiffComment creates a thread root (replyTo 0) or a reply. Replies inherit the root's anchor and must belong to the same MR.
func (*Store) AddEmail ¶
AddEmail adds an address; verifiedBy is "" (unverified), "smtp", or "admin". Adding an already-verified address bumps the key epoch: it is a trust input for signature states.
func (*Store) AddIssueComment ¶
func (*Store) AddIssueSystemComment ¶ added in v0.2.0
AddIssueSystemComment records an informational entry (commit references, automated closes). The actor is kept for provenance but the entry displays as coming from the system, not the user.
func (*Store) AddMRReview ¶
func (*Store) AddMRSystemComment ¶ added in v0.2.0
AddMRSystemComment is the informational counterpart of AddMRComment.
func (*Store) AddMirror ¶ added in v0.2.0
func (*Store) AddPGPKey ¶
func (s *Store) AddPGPKey(userID int64, fingerprint, armored, uidsJSON string, expiresAt, revokedAt *time.Time) error
AddPGPKey registers an OpenPGP key and bumps the key epoch.
func (*Store) AddPageDomain ¶ added in v0.3.0
func (s *Store) AddPageDomain(domain string, repoID, userID int64, token string, ttlSeconds int) error
AddPageDomain claims a domain for a repo. Expired pending claims (any repo's) are cleared first, so abandonment frees the name; live claims make the insert fail with ErrExists.
func (*Store) AddReleaseAsset ¶ added in v0.2.0
func (*Store) AddSSHKey ¶
AddSSHKey registers a key and bumps the key epoch in one transaction.
func (*Store) AddTeamMember ¶ added in v0.3.0
func (*Store) AddTopic ¶ added in v0.2.0
AddTopic is idempotent: adding an existing topic is not an error.
func (*Store) AddWebhook ¶
func (*Store) AppendBuildLog ¶ added in v0.3.0
AppendBuildLog adds a chunk to the build's log, dropping bytes past the cap.
func (*Store) AssignedIssues ¶ added in v0.5.0
func (s *Store) AssignedIssues(userID int64) ([]DashboardItem, error)
AssignedIssues returns open issues assigned to the user, wherever they live. Assignment is a direct request for someone's attention, so it is not narrowed by the involvement rule the other lists use.
func (*Store) Audit ¶ added in v0.2.0
Audit appends to the security feed. Events are the product feed; this records who did what, from where, for an operator. actorID 0 means the host admin (gitbayd admin commands) or an unauthenticated source.
func (*Store) AuditEntries ¶ added in v0.2.0
func (s *Store) AuditEntries(limit int) ([]AuditEntry, error)
func (*Store) BuildByNumber ¶ added in v0.3.0
func (*Store) BuildLog ¶ added in v0.3.0
BuildLog returns the stored log bytes.
func (*Store) BuildSecrets ¶ added in v0.3.0
BuildSecrets returns the values, for injection into a claimed build.
func (*Store) CachedSignature ¶
CachedSignature returns a cached result and whether it is current at the given epoch.
func (*Store) ClaimBuild ¶ added in v0.3.0
ClaimBuild atomically hands the oldest pending build to a runner.
func (*Store) ClearPending ¶
ClearPending activates a pending account.
func (*Store) CombinedStatusFor ¶ added in v1.0.0
CombinedStatus reduces per-context states to one: error/failure dominate, then pending, then success; "" when no statuses exist. CombinedStatusFor returns the combined state for each of several commits in one query. The log lists fifty commits at a time; asking per commit turns one page into fifty round trips.
func (*Store) ConsumeEmailToken ¶
ConsumeEmailToken redeems a verification code for the given user.
func (*Store) ConsumeInvite ¶
ConsumeInvite redeems an invite exactly once, returning the address it was issued for. Used and unknown codes fail identically.
func (*Store) ConsumeLoginToken ¶
ConsumeLoginToken redeems a token exactly once; expired or used tokens fail identically.
func (*Store) CreateAPIToken ¶
func (s *Store) CreateAPIToken(userID int64, name, tokenHash, scope string, expires *time.Time) error
CreateAPIToken stores a token hash; expires nil means no expiry.
func (*Store) CreateBuild ¶ added in v0.3.0
CreateBuild allocates the per-repo build number in the same transaction as the insert, like issue and MR numbers.
func (*Store) CreateEmailToken ¶
CreateEmailToken stores a verification code hash for one address.
func (*Store) CreateInvite ¶
CreateInvite stores an invite code hash bound to an email address.
func (*Store) CreateIssue ¶
CreateIssue allocates the per-repo number from the repo counter inside the same transaction as the insert — MAX(number)+1 races.
func (*Store) CreateLoginToken ¶
CreateLoginToken stores a one-time login token hash.
func (*Store) CreateMR ¶
func (*Store) CreateMilestone ¶ added in v0.2.0
func (*Store) CreateOrg ¶
CreateOrg makes an organization with the creator as its first admin.
func (*Store) CreateRegisteredUser ¶
CreateRegisteredUser makes a self-registered account, pending until its email is verified.
func (*Store) CreateRelease ¶ added in v0.2.0
func (*Store) CreateRepo ¶
func (*Store) CreateTeam ¶ added in v0.3.0
func (*Store) CreateWebSession ¶
func (*Store) DashboardIssues ¶ added in v0.2.0
func (s *Store) DashboardIssues(userID int64) ([]DashboardItem, error)
DashboardIssues is the issue counterpart of DashboardMRs.
func (*Store) DashboardMRs ¶ added in v0.2.0
func (s *Store) DashboardMRs(userID int64) ([]DashboardItem, error)
DashboardMRs returns open merge requests involving the user: on their repositories (owned, granted, org) or authored by them anywhere.
func (*Store) DeleteOrg ¶
DeleteOrg removes an empty organization; orgs still owning repositories are refused.
func (*Store) DeleteUser ¶ added in v0.3.0
DeleteUser removes an account whose removal orphans nothing: no owned repositories, no authored issues, MRs, comments, or reviews, and not the only admin of an org. Everything else (keys, emails, sessions, tokens, pins, memberships, activity) cascades. Blockers come back as an error naming what stands in the way, so the operator can transfer, delete, or disable instead.
func (*Store) DiffCommentAuthor ¶ added in v0.2.0
DiffCommentAuthor returns the author id of one comment.
func (*Store) DueDeliveries ¶
DueDeliveries returns pending deliveries whose time has come, with the event and hook context needed to send them.
func (*Store) DueMail ¶ added in v0.2.0
func (s *Store) DueMail(limit int) ([]QueuedMail, error)
func (*Store) DueMirrors ¶ added in v0.2.0
DueMirrors returns mirrors needing a sync: anything dirty, plus pull mirrors whose last sync is older than intervalSeconds.
func (*Store) DueSchedules ¶ added in v0.3.0
DueSchedules returns entries whose next_run is at or before now.
func (*Store) EmailInUse ¶ added in v0.2.0
EmailInUse reports whether an address is attached to any account.
func (*Store) EnqueueMail ¶ added in v0.2.0
func (*Store) FinishBuild ¶ added in v0.3.0
FinishBuild records the outcome of a running build.
func (*Store) GrantTeamRepo ¶ added in v0.3.0
GrantTeamRepo attaches (or updates) a team's role on a repo.
func (*Store) ImportMarker ¶ added in v0.2.0
ImportMarker returns the stored value for an import progress key, and whether it exists. Markers make history imports resumable: items and comments already imported are skipped on re-run.
func (*Store) IssueParticipants ¶ added in v0.2.0
IssueParticipants returns distinct user ids involved in an issue: the author and every commenter.
func (*Store) LFSSecret ¶ added in v0.4.0
LFSSecret returns the instance's LFS token-signing secret, minting and persisting one on first use. gen supplies the new value so this package stays free of crypto choices.
func (*Store) LabelColors ¶ added in v0.2.0
LabelColors returns the repo's label colors keyed by label name. Labels with no stored color map to "".
func (*Store) LatestBuild ¶ added in v0.5.0
LatestBuild returns the newest build for a repo, optionally narrowed to one job. It is what a status badge reports.
func (*Store) ListAccess ¶
func (s *Store) ListAccess(repoID int64) ([]AccessEntry, error)
func (*Store) ListAllRepos ¶ added in v0.2.0
ListAllRepos returns every repository, for host-local admin tooling.
func (*Store) ListBuildSecretNames ¶ added in v0.3.0
ListBuildSecretNames returns names only; values are for builds.
func (*Store) ListBuilds ¶ added in v0.3.0
func (*Store) ListCommitStatuses ¶ added in v0.2.0
func (s *Store) ListCommitStatuses(repoID int64, sha string) ([]CommitStatus, error)
ListCommitStatuses returns the latest status per context for a commit.
func (*Store) ListDeliveries ¶
func (s *Store) ListDeliveries(repoID int64, limit int) ([]DeliveryStatus, error)
func (*Store) ListDeployKeys ¶ added in v0.2.0
ListDeployKeys returns the deploy keys bound to a repository.
func (*Store) ListDiffComments ¶ added in v0.2.0
func (s *Store) ListDiffComments(mrID int64) ([]DiffComment, error)
ListDiffComments returns every diff comment on an MR, roots and replies, oldest first.
func (*Store) ListEmails ¶ added in v1.0.0
ListEmails returns every address on the account with its state.
func (*Store) ListIssueComments ¶
func (s *Store) ListIssueComments(issueID int64) ([]IssueComment, error)
func (*Store) ListIssueLabels ¶ added in v0.2.0
ListIssueLabels returns the label names attached to each issue of a repo, keyed by issue id. Used by the web issue listing; ListIssues itself stays label-free for the CLI's lean list output.
func (*Store) ListIssues ¶
ListIssues returns issues for a repo; state is "open", "closed", or "all".
func (*Store) ListMRComments ¶
func (s *Store) ListMRComments(mrID int64) ([]IssueComment, error)
func (*Store) ListMilestones ¶ added in v0.2.0
func (*Store) ListMirrors ¶ added in v0.2.0
func (*Store) ListOrgsForUser ¶
ListOrgsForUser returns the orgs the user belongs to, with their role.
func (*Store) ListPageDomains ¶ added in v0.3.0
func (s *Store) ListPageDomains(repoID int64) ([]PageDomain, error)
func (*Store) ListPublicRepos ¶
ListPublicRepos returns all public repositories, for the anonymous index.
func (*Store) ListReleases ¶ added in v0.2.0
ListReleases returns releases newest-first, assets included.
func (*Store) ListReposForOwner ¶
ListReposForOwner returns every repo owned by one user or org; the caller filters by viewer visibility.
func (*Store) ListReposForUser ¶
ListReposForUser returns repos the user owns, reaches through an org (unless the org scopes members to 'none'), has an explicit grant on, or reaches through a team.
func (*Store) ListTopics ¶ added in v0.2.0
func (*Store) MRParticipants ¶ added in v0.2.0
MRParticipants returns distinct user ids involved in an MR: author, commenters, reviewers.
func (*Store) MarkAttemptFailed ¶
MarkAttemptFailed records a failed attempt; nextAt nil dead-letters it.
func (*Store) MarkMailFailed ¶ added in v0.2.0
func (*Store) MarkMerged ¶
MarkMerged records the merge along with the target tip it landed on, so the MR's diff stays reconstructable after fast-forwards.
func (*Store) MarkMirrorsDirty ¶ added in v0.2.0
MarkMirrorsDirty schedules a sync. An empty direction marks both.
func (*Store) MarkSourceGoneForRepo ¶
MarkSourceGoneForRepo flags every open MR sourced from the repo; called when a fork is deleted. Head refs in the target repos are retained.
func (*Store) MigrateCommitRefComments ¶ added in v0.3.0
MigrateCommitRefComments converts legacy commit-reference comments into system messages with a linked sha, matching what new references produce. It is idempotent: only kind='comment' rows are considered, and converted rows become kind='system'. Returns the number converted.
func (*Store) MigrateTo ¶
MigrateTo migrates up or down to the given version. 0 empties the schema.
func (*Store) MigrateUp ¶
MigrateUp applies all pending migrations.
func (*Store) MilestoneByTitle ¶ added in v0.2.0
func (*Store) OpenCounts ¶ added in v0.5.0
OpenCounts returns the repo's open issue and open merge request counts, for the repo tab badges.
func (*Store) OpenMRsBySource ¶
OpenMRsBySource returns open (and source_gone) MRs fed by the given source repo branch — the cross-repo hook effect consults this.
func (*Store) OrgActivityByDay ¶ added in v0.3.0
OrgActivityByDay aggregates activity across an org's repositories.
func (*Store) OrgRole ¶
OrgRole returns the user's role in the org ("" for non-members).
func (*Store) OwnerExists ¶ added in v0.3.0
OwnerExists reports whether a user or org owns the name — the ACME host policy check for pages subdomains.
func (*Store) OwnerProfile ¶
OwnerProfile reads the profile for kind "user" or "org".
func (*Store) PageDomainClaim ¶ added in v0.3.0
func (s *Store) PageDomainClaim(domain string, repoID int64) (PageDomain, error)
PageDomainClaim returns a repo's claim on a domain, verified or pending.
func (*Store) PageDomainExpired ¶ added in v0.3.0
func (s *Store) PageDomainExpired(d PageDomain, ttlSeconds int) bool
PageDomainExpired reports whether a pending claim has outlived the TTL.
func (*Store) PageDomainRepo ¶ added in v0.3.0
PageDomainRepo resolves a request host to the repo serving it. Only verified claims serve.
func (*Store) PinnedRepos ¶ added in v0.2.0
PinnedRepos returns the user's pinned repositories in pin order. The caller applies visibility checks before rendering.
func (*Store) PrimaryVerifiedEmail ¶
PrimaryVerifiedEmail returns the user's primary email if verified, else "".
func (*Store) PullMirrored ¶ added in v0.2.0
PullMirrored reports whether the repo has a pull mirror, which makes it read-only locally: its refs belong to the upstream.
func (*Store) RecentEvents ¶ added in v0.5.0
RecentEvents returns activity on repositories the user can reach. Push events are excluded: they repeat what the commit lists already show.
func (*Store) RecordCommitActivity ¶ added in v0.3.0
RecordCommitActivity is idempotent per (repo, sha); it reports whether this call recorded a new row.
func (*Store) RecordEvent ¶
RecordEvent appends to the event log and enqueues a delivery for every active webhook on the repo whose event filter matches.
func (*Store) RedeemInvite ¶ added in v0.2.0
func (s *Store) RedeemInvite(codeHash, username, keyFP, keyAlgo string, keyBlob []byte) (string, error)
RedeemInvite performs the whole invite registration in one transaction: consume the code, create the user, attach the invite's email as verified, register the key. Any failure rolls everything back — the invite stays redeemable and no partial account exists.
func (*Store) Redeliver ¶
Redeliver resets a delivery for an immediate retry.
func (*Store) RegisterOpen ¶ added in v0.2.0
RegisterOpen performs open registration in one transaction: pending user, unverified email, key. Failure leaves nothing behind.
func (*Store) ReleaseByTag ¶ added in v0.2.0
func (*Store) RemoveBuildSecret ¶ added in v0.3.0
func (*Store) RemoveDeployKey ¶ added in v0.2.0
RemoveDeployKey removes a deploy key from a repository by fingerprint; any repo admin may remove it regardless of who added it.
func (*Store) RemoveOrgMember ¶
RemoveOrgMember drops a member, refusing to remove the last admin.
func (*Store) RemovePageDomain ¶ added in v0.3.0
func (*Store) RemoveReleaseAsset ¶ added in v0.2.0
func (*Store) RemoveSSHKey ¶
RemoveSSHKey removes a key owned by userID and bumps the key epoch.
func (*Store) RemoveSchedule ¶ added in v0.3.0
func (*Store) RemoveTeamMember ¶ added in v0.3.0
func (*Store) RemoveTopic ¶ added in v0.2.0
func (*Store) RenameOrg ¶
RenameOrg changes an org's name, holding the shared owner-namespace invariant. The caller moves the on-disk repos directory afterward.
func (*Store) RepoByPath ¶
RepoByPath resolves "owner/name"; the owner may be a user or an org.
func (*Store) RepoNotifyTargets ¶ added in v0.2.0
RepoNotifyTargets returns who should hear about new activity on a repo: the owning user, or every admin of the owning org.
func (*Store) ReviewQueue ¶ added in v0.5.0
func (s *Store) ReviewQueue(userID int64) ([]DashboardItem, error)
ReviewQueue returns open merge requests the user is involved in, has not authored, and has not reviewed at the current head — what the rail shows as waiting on them. Ordered most recently touched first.
func (*Store) RevokeTeamRepo ¶ added in v0.3.0
func (*Store) SSHKeyByFingerprint ¶
func (*Store) SetBuildSecret ¶ added in v0.3.0
SetBuildSecret stores or replaces one secret. The value never leaves the server except inside a claimed build's environment.
func (*Store) SetCommitStatus ¶ added in v0.2.0
func (s *Store) SetCommitStatus(repoID int64, sha, context, state, description, targetURL string, creatorID int64) error
SetCommitStatus upserts the latest state for one context on one commit. A zero creatorID records no creator (system actions like the scheduler).
func (*Store) SetImportMarker ¶ added in v0.2.0
func (*Store) SetIssueAssignee ¶
SetIssueAssignee adds or removes an assignee by user id.
func (*Store) SetIssueLabel ¶
SetIssueLabel attaches (add) or detaches a label, creating the repo label on first use.
func (*Store) SetIssueMilestone ¶ added in v0.2.0
SetIssueMilestone attaches (or with milestoneID 0 clears) a milestone.
func (*Store) SetMRMilestone ¶ added in v0.2.0
func (*Store) SetMilestoneState ¶ added in v0.2.0
func (*Store) SetMirrorResult ¶ added in v0.2.0
SetMirrorResult records a sync outcome and clears the dirty flag.
func (*Store) SetOrgMember ¶
SetOrgMember adds a member or updates their role. Demoting the last admin is refused: an org must always have one.
func (*Store) SetOrgMembersRole ¶ added in v0.3.0
func (*Store) SetOwnerProfile ¶
SetOwnerProfile updates the profile for kind "user" or "org".
func (*Store) SetRepoSettings ¶
func (s *Store) SetRepoSettings(repoID int64, settings RepoSettings) error
func (*Store) SetRepoVisibility ¶ added in v0.5.0
SetRepoVisibility switches a repository between public and private.
func (*Store) SetScheduleNext ¶ added in v0.3.0
SetScheduleNext advances one entry's next firing time.
func (*Store) SetThreadResolved ¶ added in v0.2.0
SetThreadResolved resolves or unresolves a thread root.
func (*Store) SetUserDisabled ¶ added in v0.2.0
SetUserDisabled suspends or restores an account. Disabling also drops the user's web sessions; their keys and tokens stay registered but are refused at every entry point until re-enabled.
func (*Store) StoreSignature ¶
func (*Store) SyncSchedules ¶ added in v0.3.0
SyncSchedules replaces a repo's schedule set with the given entries, preserving next_run for entries whose cron is unchanged.
func (*Store) TeamByName ¶ added in v0.3.0
func (*Store) TeamGrants ¶ added in v0.3.0
func (*Store) TeamMembers ¶ added in v0.3.0
func (*Store) TouchSSHKey ¶
TouchSSHKey records key use; best-effort, callers ignore the error.
func (*Store) TransferRepo ¶
TransferRepo moves a repository to a new owner. The unique index on (owner_kind, owner_id, name) refuses collisions in the target namespace.
func (*Store) TryRecordCommitRef ¶ added in v0.2.0
TryRecordCommitRef marks a commit as having referenced an issue. It reports whether this pair was new — false means the reference was already processed and must not act again.
func (*Store) UnresolvedThreadCount ¶ added in v0.2.0
UnresolvedThreadCount counts unresolved thread roots on an MR.
func (*Store) UpdateDefaultBranch ¶
func (*Store) UpdateIssueText ¶ added in v0.2.0
UpdateIssueText edits title and/or body; nil leaves a field unchanged.
func (*Store) UpdateMRHead ¶
UpdateMRHead records a new head and marks every review at another head stale, in one transaction.
func (*Store) UpdateMRText ¶ added in v0.2.0
UpdateMRText edits title and/or body; nil leaves a field unchanged.
func (*Store) UpdateRelease ¶ added in v0.4.0
UpdateRelease replaces a release's title and notes.
func (*Store) UserEmailAddresses ¶ added in v0.2.0
UserEmailAddresses returns every address on the account, verified or not.
func (*Store) UserIDByVerifiedEmail ¶ added in v0.3.0
UserIDByVerifiedEmail resolves a commit author email to an account, only through addresses the account has verified — the same trust rule as signature attribution.
func (*Store) UsernameByVerifiedEmail ¶ added in v0.5.0
UsernameByVerifiedEmail resolves a commit author address to the account that has proven it, so the forge can show its own name for a person rather than whatever git config happened to be set.
func (*Store) VerifyEmail ¶
VerifyEmail marks an address verified and bumps the key epoch (email verification is a trust input for signature states).
func (*Store) VerifyPageDomain ¶ added in v0.3.0
VerifyPageDomain activates a pending claim.
func (*Store) Version ¶
Version returns the current schema version (0 = empty database).
type TeamGrant ¶ added in v0.3.0
type User ¶
Source Files
¶
- activity.go
- audit.go
- builds.go
- cisecrets.go
- commentmigrate.go
- commitrefs.go
- dashboard.go
- diffcomments.go
- importmarkers.go
- issues.go
- lfs.go
- milestones.go
- mirrors.go
- mrs.go
- notify.go
- orgs.go
- pagedomains.go
- registration.go
- releases.go
- repos.go
- sessions.go
- signatures.go
- stats.go
- statuses.go
- store.go
- teams.go
- tokens.go
- topics.go
- users.go
- webhooks.go