Documentation
¶
Index ¶
- type AuditAction
- type AuditEntityType
- type AuditEntry
- type AuditQueryOpts
- type AuthCode
- type AuthProvider
- type Group
- type HistoryQueryOpts
- type HistoryResult
- type HistoryStatsBucket
- type HistoryStatsOpts
- type HistoryStatsRange
- type HistoryStatsResult
- type HistoryStatsTotals
- type Job
- type JobStatus
- type JobTemplate
- type OAuthState
- type PostgresStore
- func (s *PostgresStore) CreateAuditEntry(ctx context.Context, entry *AuditEntry) error
- func (s *PostgresStore) CreateAuthCode(ctx context.Context, code *AuthCode) error
- func (s *PostgresStore) CreateGroup(ctx context.Context, group *Group) error
- func (s *PostgresStore) CreateJob(ctx context.Context, job *Job) error
- func (s *PostgresStore) CreateJobTemplate(ctx context.Context, template *JobTemplate) error
- func (s *PostgresStore) CreateOAuthState(ctx context.Context, state *OAuthState) error
- func (s *PostgresStore) CreateSession(ctx context.Context, session *Session) error
- func (s *PostgresStore) CreateUser(ctx context.Context, user *User) error
- func (s *PostgresStore) DeleteAuthCode(ctx context.Context, code string) error
- func (s *PostgresStore) DeleteExpiredAuthCodes(ctx context.Context) error
- func (s *PostgresStore) DeleteExpiredOAuthStates(ctx context.Context) error
- func (s *PostgresStore) DeleteExpiredSessions(ctx context.Context) error
- func (s *PostgresStore) DeleteGroup(ctx context.Context, id string) error
- func (s *PostgresStore) DeleteJob(ctx context.Context, id string) error
- func (s *PostgresStore) DeleteJobTemplate(ctx context.Context, id string) error
- func (s *PostgresStore) DeleteJobTemplatesByGroup(ctx context.Context, groupID string) error
- func (s *PostgresStore) DeleteOAuthState(ctx context.Context, state string) error
- func (s *PostgresStore) DeleteOldJobs(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *PostgresStore) DeleteRunner(ctx context.Context, id int64) error
- func (s *PostgresStore) DeleteSession(ctx context.Context, id string) error
- func (s *PostgresStore) DeleteStaleRunners(ctx context.Context, olderThan time.Time) error
- func (s *PostgresStore) DeleteUser(ctx context.Context, id string) error
- func (s *PostgresStore) DeleteUserSessions(ctx context.Context, userID string) error
- func (s *PostgresStore) GetAuthCode(ctx context.Context, code string) (*AuthCode, error)
- func (s *PostgresStore) GetGroup(ctx context.Context, id string) (*Group, error)
- func (s *PostgresStore) GetHistoryStats(ctx context.Context, opts HistoryStatsOpts) (*HistoryStatsResult, error)
- func (s *PostgresStore) GetHistoryTimeBounds(ctx context.Context, groupID string) (oldest, newest *time.Time, err error)
- func (s *PostgresStore) GetJob(ctx context.Context, id string) (*Job, error)
- func (s *PostgresStore) GetJobTemplate(ctx context.Context, id string) (*JobTemplate, error)
- func (s *PostgresStore) GetMaxPosition(ctx context.Context, groupID string) (int, error)
- func (s *PostgresStore) GetNextPendingJob(ctx context.Context, groupID string) (*Job, error)
- func (s *PostgresStore) GetOAuthState(ctx context.Context, state string) (*OAuthState, error)
- func (s *PostgresStore) GetRunner(ctx context.Context, id int64) (*Runner, error)
- func (s *PostgresStore) GetRunnerByName(ctx context.Context, name string) (*Runner, error)
- func (s *PostgresStore) GetSession(ctx context.Context, id string) (*Session, error)
- func (s *PostgresStore) GetSessionByToken(ctx context.Context, tokenHash string) (*Session, error)
- func (s *PostgresStore) GetUser(ctx context.Context, id string) (*User, error)
- func (s *PostgresStore) GetUserByGitHubID(ctx context.Context, githubID string) (*User, error)
- func (s *PostgresStore) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (s *PostgresStore) HasAnyJobs(ctx context.Context, templateID string) (bool, error)
- func (s *PostgresStore) ListAuditEntries(ctx context.Context, opts AuditQueryOpts) ([]*AuditEntry, int, error)
- func (s *PostgresStore) ListGroups(ctx context.Context) ([]*Group, error)
- func (s *PostgresStore) ListJobHistory(ctx context.Context, opts HistoryQueryOpts) (*HistoryResult, error)
- func (s *PostgresStore) ListJobTemplatesByGroup(ctx context.Context, groupID string) ([]*JobTemplate, error)
- func (s *PostgresStore) ListJobsByGroup(ctx context.Context, groupID string, statuses ...JobStatus) ([]*Job, error)
- func (s *PostgresStore) ListJobsByStatus(ctx context.Context, statuses ...JobStatus) ([]*Job, error)
- func (s *PostgresStore) ListRunners(ctx context.Context) ([]*Runner, error)
- func (s *PostgresStore) ListRunnersByLabels(ctx context.Context, labels []string) ([]*Runner, error)
- func (s *PostgresStore) Migrate(ctx context.Context) error
- func (s *PostgresStore) Ping(ctx context.Context) error
- func (s *PostgresStore) ReorderJobs(ctx context.Context, groupID string, jobIDs []string) error
- func (s *PostgresStore) Start(ctx context.Context) error
- func (s *PostgresStore) Stop() error
- func (s *PostgresStore) UpdateGroup(ctx context.Context, group *Group) error
- func (s *PostgresStore) UpdateJob(ctx context.Context, job *Job) error
- func (s *PostgresStore) UpdateJobTemplate(ctx context.Context, template *JobTemplate) error
- func (s *PostgresStore) UpdateTemplateInConfig(ctx context.Context, id string, inConfig bool) error
- func (s *PostgresStore) UpdateUser(ctx context.Context, user *User) error
- func (s *PostgresStore) UpsertRunner(ctx context.Context, runner *Runner) error
- type Role
- type Runner
- type RunnerStatus
- type SQLiteStore
- func (s *SQLiteStore) CreateAuditEntry(ctx context.Context, entry *AuditEntry) error
- func (s *SQLiteStore) CreateAuthCode(ctx context.Context, code *AuthCode) error
- func (s *SQLiteStore) CreateGroup(ctx context.Context, group *Group) error
- func (s *SQLiteStore) CreateJob(ctx context.Context, job *Job) error
- func (s *SQLiteStore) CreateJobTemplate(ctx context.Context, template *JobTemplate) error
- func (s *SQLiteStore) CreateOAuthState(ctx context.Context, state *OAuthState) error
- func (s *SQLiteStore) CreateSession(ctx context.Context, session *Session) error
- func (s *SQLiteStore) CreateUser(ctx context.Context, user *User) error
- func (s *SQLiteStore) DeleteAuthCode(ctx context.Context, code string) error
- func (s *SQLiteStore) DeleteExpiredAuthCodes(ctx context.Context) error
- func (s *SQLiteStore) DeleteExpiredOAuthStates(ctx context.Context) error
- func (s *SQLiteStore) DeleteExpiredSessions(ctx context.Context) error
- func (s *SQLiteStore) DeleteGroup(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteJob(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteJobTemplate(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteJobTemplatesByGroup(ctx context.Context, groupID string) error
- func (s *SQLiteStore) DeleteOAuthState(ctx context.Context, state string) error
- func (s *SQLiteStore) DeleteOldJobs(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *SQLiteStore) DeleteRunner(ctx context.Context, id int64) error
- func (s *SQLiteStore) DeleteSession(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteStaleRunners(ctx context.Context, olderThan time.Time) error
- func (s *SQLiteStore) DeleteUser(ctx context.Context, id string) error
- func (s *SQLiteStore) DeleteUserSessions(ctx context.Context, userID string) error
- func (s *SQLiteStore) GetAuthCode(ctx context.Context, code string) (*AuthCode, error)
- func (s *SQLiteStore) GetGroup(ctx context.Context, id string) (*Group, error)
- func (s *SQLiteStore) GetHistoryStats(ctx context.Context, opts HistoryStatsOpts) (*HistoryStatsResult, error)
- func (s *SQLiteStore) GetHistoryTimeBounds(ctx context.Context, groupID string) (oldest, newest *time.Time, err error)
- func (s *SQLiteStore) GetJob(ctx context.Context, id string) (*Job, error)
- func (s *SQLiteStore) GetJobTemplate(ctx context.Context, id string) (*JobTemplate, error)
- func (s *SQLiteStore) GetMaxPosition(ctx context.Context, groupID string) (int, error)
- func (s *SQLiteStore) GetNextPendingJob(ctx context.Context, groupID string) (*Job, error)
- func (s *SQLiteStore) GetOAuthState(ctx context.Context, state string) (*OAuthState, error)
- func (s *SQLiteStore) GetRunner(ctx context.Context, id int64) (*Runner, error)
- func (s *SQLiteStore) GetRunnerByName(ctx context.Context, name string) (*Runner, error)
- func (s *SQLiteStore) GetSession(ctx context.Context, id string) (*Session, error)
- func (s *SQLiteStore) GetSessionByToken(ctx context.Context, tokenHash string) (*Session, error)
- func (s *SQLiteStore) GetUser(ctx context.Context, id string) (*User, error)
- func (s *SQLiteStore) GetUserByGitHubID(ctx context.Context, githubID string) (*User, error)
- func (s *SQLiteStore) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (s *SQLiteStore) HasAnyJobs(ctx context.Context, templateID string) (bool, error)
- func (s *SQLiteStore) ListAuditEntries(ctx context.Context, opts AuditQueryOpts) ([]*AuditEntry, int, error)
- func (s *SQLiteStore) ListGroups(ctx context.Context) ([]*Group, error)
- func (s *SQLiteStore) ListJobHistory(ctx context.Context, opts HistoryQueryOpts) (*HistoryResult, error)
- func (s *SQLiteStore) ListJobTemplatesByGroup(ctx context.Context, groupID string) ([]*JobTemplate, error)
- func (s *SQLiteStore) ListJobsByGroup(ctx context.Context, groupID string, statuses ...JobStatus) ([]*Job, error)
- func (s *SQLiteStore) ListJobsByStatus(ctx context.Context, statuses ...JobStatus) ([]*Job, error)
- func (s *SQLiteStore) ListRunners(ctx context.Context) ([]*Runner, error)
- func (s *SQLiteStore) ListRunnersByLabels(ctx context.Context, labels []string) ([]*Runner, error)
- func (s *SQLiteStore) Migrate(ctx context.Context) error
- func (s *SQLiteStore) Ping(ctx context.Context) error
- func (s *SQLiteStore) ReorderJobs(ctx context.Context, groupID string, jobIDs []string) error
- func (s *SQLiteStore) Start(ctx context.Context) error
- func (s *SQLiteStore) Stop() error
- func (s *SQLiteStore) UpdateGroup(ctx context.Context, group *Group) error
- func (s *SQLiteStore) UpdateJob(ctx context.Context, job *Job) error
- func (s *SQLiteStore) UpdateJobTemplate(ctx context.Context, template *JobTemplate) error
- func (s *SQLiteStore) UpdateTemplateInConfig(ctx context.Context, id string, inConfig bool) error
- func (s *SQLiteStore) UpdateUser(ctx context.Context, user *User) error
- func (s *SQLiteStore) UpsertRunner(ctx context.Context, runner *Runner) error
- type Session
- type Store
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditAction ¶
type AuditAction string
AuditAction represents the type of action being audited.
const ( AuditActionJobCreated AuditAction = "job_created" AuditActionJobTriggered AuditAction = "job_triggered" AuditActionJobCompleted AuditAction = "job_completed" AuditActionJobFailed AuditAction = "job_failed" AuditActionJobCancelled AuditAction = "job_cancelled" AuditActionJobReordered AuditAction = "job_reordered" AuditActionUserLogin AuditAction = "user_login" AuditActionUserLogout AuditAction = "user_logout" AuditActionConfigReload AuditAction = "config_reload" )
type AuditEntityType ¶
type AuditEntityType string
AuditEntityType represents the type of entity being audited.
const ( AuditEntityJob AuditEntityType = "job" AuditEntityGroup AuditEntityType = "group" AuditEntityRunner AuditEntityType = "runner" AuditEntityUser AuditEntityType = "user" AuditEntitySession AuditEntityType = "session" AuditEntitySystem AuditEntityType = "system" )
type AuditEntry ¶
type AuditEntry struct {
ID string `json:"id"`
Action AuditAction `json:"action"`
EntityType AuditEntityType `json:"entity_type"`
EntityID string `json:"entity_id"`
Actor string `json:"actor"`
Details string `json:"details"`
CreatedAt time.Time `json:"created_at"`
}
AuditEntry represents an audit log entry.
type AuditQueryOpts ¶
type AuditQueryOpts struct {
EntityType *AuditEntityType
EntityID *string
Action *AuditAction
Actor *string
Since *time.Time
Until *time.Time
Limit int
Offset int
}
AuditQueryOpts contains options for querying audit entries.
type AuthCode ¶
type AuthCode struct {
Code string `json:"code"`
UserID string `json:"user_id"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
AuthCode represents a one-time authorization code for token exchange.
type AuthProvider ¶
type AuthProvider string
AuthProvider represents the authentication provider for a user.
const ( AuthProviderBasic AuthProvider = "basic" AuthProviderGitHub AuthProvider = "github" )
type Group ¶
type Group struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
RunnerLabels []string `json:"runner_labels"`
Enabled bool `json:"enabled"`
Paused bool `json:"paused"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Group represents a runner pool.
type HistoryQueryOpts ¶
type HistoryQueryOpts struct {
GroupID string
Limit int
Before *time.Time // cursor: fetch jobs completed before this time
Statuses []JobStatus // filter by status (multi-select, empty = all history statuses)
Labels map[string]string // filter by template labels (AND logic)
}
HistoryQueryOpts contains options for querying job history.
type HistoryResult ¶
type HistoryResult struct {
Jobs []*Job
HasMore bool
NextCursor *time.Time // completed_at of the last job
TotalCount int
}
HistoryResult contains paginated history results.
type HistoryStatsBucket ¶
type HistoryStatsBucket struct {
Timestamp time.Time `json:"timestamp"`
Completed int `json:"completed"`
Failed int `json:"failed"`
Cancelled int `json:"cancelled"`
}
HistoryStatsBucket contains aggregated job counts for a time bucket.
type HistoryStatsOpts ¶
type HistoryStatsOpts struct {
GroupID string
Start time.Time
End time.Time
Buckets int // number of time buckets to return
}
HistoryStatsOpts contains options for querying history statistics.
type HistoryStatsRange ¶
type HistoryStatsRange struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
BucketDuration time.Duration `json:"bucket_duration"`
}
HistoryStatsRange contains metadata about the time range.
type HistoryStatsResult ¶
type HistoryStatsResult struct {
Buckets []*HistoryStatsBucket `json:"buckets"`
Range HistoryStatsRange `json:"range"`
Totals HistoryStatsTotals `json:"totals"`
}
HistoryStatsResult contains aggregated history statistics.
type HistoryStatsTotals ¶
type HistoryStatsTotals struct {
Completed int `json:"completed"`
Failed int `json:"failed"`
Cancelled int `json:"cancelled"`
}
HistoryStatsTotals contains total counts across all buckets.
type Job ¶
type Job struct {
ID string `json:"id"`
GroupID string `json:"group_id"`
TemplateID string `json:"template_id"`
Priority int `json:"priority"`
Position int `json:"position"`
Status JobStatus `json:"status"`
Paused bool `json:"paused"`
AutoRequeue bool `json:"auto_requeue"`
RequeueLimit *int `json:"requeue_limit"`
RequeueCount int `json:"requeue_count"`
Inputs map[string]string `json:"inputs"`
CreatedBy string `json:"created_by"`
TriggeredAt *time.Time `json:"triggered_at"`
RunID *int64 `json:"run_id"`
RunURL string `json:"run_url"`
RunnerID *int64 `json:"runner_id"`
RunnerName string `json:"runner_name"`
CompletedAt *time.Time `json:"completed_at"`
ErrorMessage string `json:"error_message"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Override fields (nil/empty means use template value).
Name *string `json:"name,omitempty"`
Owner *string `json:"owner,omitempty"`
Repo *string `json:"repo,omitempty"`
WorkflowID *string `json:"workflow_id,omitempty"`
Ref *string `json:"ref,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
Job represents a queued or executed workflow dispatch.
type JobTemplate ¶
type JobTemplate struct {
ID string `json:"id"`
GroupID string `json:"group_id"`
Name string `json:"name"`
Owner string `json:"owner"`
Repo string `json:"repo"`
WorkflowID string `json:"workflow_id"`
Ref string `json:"ref"`
DefaultInputs map[string]string `json:"default_inputs"`
Labels map[string]string `json:"labels"`
InConfig bool `json:"in_config"`
SourceType string `json:"source_type"` // "inline", "file", or "url"
SourcePath string `json:"source_path"` // filename or URL (empty for inline)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
JobTemplate represents a workflow dispatch job configuration.
type OAuthState ¶
type OAuthState struct {
State string `json:"state"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
OAuthState represents a CSRF state token for OAuth flows.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements Store using PostgreSQL.
func (*PostgresStore) CreateAuditEntry ¶
func (s *PostgresStore) CreateAuditEntry(ctx context.Context, entry *AuditEntry) error
CreateAuditEntry creates a new audit log entry.
func (*PostgresStore) CreateAuthCode ¶
func (s *PostgresStore) CreateAuthCode(ctx context.Context, code *AuthCode) error
CreateAuthCode creates a new one-time authorization code.
func (*PostgresStore) CreateGroup ¶
func (s *PostgresStore) CreateGroup(ctx context.Context, group *Group) error
CreateGroup creates a new group.
func (*PostgresStore) CreateJob ¶
func (s *PostgresStore) CreateJob(ctx context.Context, job *Job) error
CreateJob creates a new job.
func (*PostgresStore) CreateJobTemplate ¶
func (s *PostgresStore) CreateJobTemplate(ctx context.Context, template *JobTemplate) error
CreateJobTemplate creates a new job template.
func (*PostgresStore) CreateOAuthState ¶
func (s *PostgresStore) CreateOAuthState(ctx context.Context, state *OAuthState) error
CreateOAuthState creates a new OAuth state for CSRF protection.
func (*PostgresStore) CreateSession ¶
func (s *PostgresStore) CreateSession(ctx context.Context, session *Session) error
CreateSession creates a new session.
func (*PostgresStore) CreateUser ¶
func (s *PostgresStore) CreateUser(ctx context.Context, user *User) error
CreateUser creates a new user.
func (*PostgresStore) DeleteAuthCode ¶
func (s *PostgresStore) DeleteAuthCode(ctx context.Context, code string) error
DeleteAuthCode deletes an authorization code.
func (*PostgresStore) DeleteExpiredAuthCodes ¶
func (s *PostgresStore) DeleteExpiredAuthCodes(ctx context.Context) error
DeleteExpiredAuthCodes deletes all expired authorization codes.
func (*PostgresStore) DeleteExpiredOAuthStates ¶
func (s *PostgresStore) DeleteExpiredOAuthStates(ctx context.Context) error
DeleteExpiredOAuthStates deletes all expired OAuth states.
func (*PostgresStore) DeleteExpiredSessions ¶
func (s *PostgresStore) DeleteExpiredSessions(ctx context.Context) error
DeleteExpiredSessions deletes all expired sessions.
func (*PostgresStore) DeleteGroup ¶
func (s *PostgresStore) DeleteGroup(ctx context.Context, id string) error
DeleteGroup deletes a group by ID.
func (*PostgresStore) DeleteJob ¶
func (s *PostgresStore) DeleteJob(ctx context.Context, id string) error
DeleteJob deletes a job by ID.
func (*PostgresStore) DeleteJobTemplate ¶
func (s *PostgresStore) DeleteJobTemplate(ctx context.Context, id string) error
DeleteJobTemplate deletes a job template by ID.
func (*PostgresStore) DeleteJobTemplatesByGroup ¶
func (s *PostgresStore) DeleteJobTemplatesByGroup(ctx context.Context, groupID string) error
DeleteJobTemplatesByGroup deletes all job templates for a group.
func (*PostgresStore) DeleteOAuthState ¶
func (s *PostgresStore) DeleteOAuthState(ctx context.Context, state string) error
DeleteOAuthState deletes an OAuth state.
func (*PostgresStore) DeleteOldJobs ¶
DeleteOldJobs deletes completed, failed, or cancelled jobs older than the given time.
func (*PostgresStore) DeleteRunner ¶
func (s *PostgresStore) DeleteRunner(ctx context.Context, id int64) error
DeleteRunner deletes a runner by ID.
func (*PostgresStore) DeleteSession ¶
func (s *PostgresStore) DeleteSession(ctx context.Context, id string) error
DeleteSession deletes a session by ID.
func (*PostgresStore) DeleteStaleRunners ¶
DeleteStaleRunners deletes runners not seen since the given time.
func (*PostgresStore) DeleteUser ¶
func (s *PostgresStore) DeleteUser(ctx context.Context, id string) error
DeleteUser deletes a user by ID.
func (*PostgresStore) DeleteUserSessions ¶
func (s *PostgresStore) DeleteUserSessions(ctx context.Context, userID string) error
DeleteUserSessions deletes all sessions for a user.
func (*PostgresStore) GetAuthCode ¶
GetAuthCode retrieves an authorization code by its value.
func (*PostgresStore) GetHistoryStats ¶
func (s *PostgresStore) GetHistoryStats(ctx context.Context, opts HistoryStatsOpts) (*HistoryStatsResult, error)
GetHistoryStats retrieves aggregated job statistics for a time range.
func (*PostgresStore) GetHistoryTimeBounds ¶
func (s *PostgresStore) GetHistoryTimeBounds(ctx context.Context, groupID string) (oldest, newest *time.Time, err error)
GetHistoryTimeBounds returns the oldest and newest completed_at times for history jobs.
func (*PostgresStore) GetJobTemplate ¶
func (s *PostgresStore) GetJobTemplate(ctx context.Context, id string) (*JobTemplate, error)
GetJobTemplate retrieves a job template by ID.
func (*PostgresStore) GetMaxPosition ¶
GetMaxPosition returns the maximum position for jobs in a group.
func (*PostgresStore) GetNextPendingJob ¶
GetNextPendingJob retrieves the next pending job for a group (lowest position). Paused jobs are excluded from selection.
func (*PostgresStore) GetOAuthState ¶
func (s *PostgresStore) GetOAuthState(ctx context.Context, state string) (*OAuthState, error)
GetOAuthState retrieves an OAuth state by its value.
func (*PostgresStore) GetRunnerByName ¶
GetRunnerByName retrieves a runner by name.
func (*PostgresStore) GetSession ¶
GetSession retrieves a session by ID.
func (*PostgresStore) GetSessionByToken ¶
GetSessionByToken retrieves a session by token hash.
func (*PostgresStore) GetUserByGitHubID ¶
GetUserByGitHubID retrieves a user by GitHub ID.
func (*PostgresStore) GetUserByUsername ¶
GetUserByUsername retrieves a user by username.
func (*PostgresStore) HasAnyJobs ¶
HasAnyJobs checks if a template has any jobs (regardless of status).
func (*PostgresStore) ListAuditEntries ¶
func (s *PostgresStore) ListAuditEntries( ctx context.Context, opts AuditQueryOpts, ) ([]*AuditEntry, int, error)
ListAuditEntries retrieves audit entries with filtering and pagination.
func (*PostgresStore) ListGroups ¶
func (s *PostgresStore) ListGroups(ctx context.Context) ([]*Group, error)
ListGroups retrieves all groups.
func (*PostgresStore) ListJobHistory ¶
func (s *PostgresStore) ListJobHistory(ctx context.Context, opts HistoryQueryOpts) (*HistoryResult, error)
ListJobHistory retrieves paginated job history with cursor-based pagination.
func (*PostgresStore) ListJobTemplatesByGroup ¶
func (s *PostgresStore) ListJobTemplatesByGroup(ctx context.Context, groupID string) ([]*JobTemplate, error)
ListJobTemplatesByGroup retrieves all job templates for a group.
func (*PostgresStore) ListJobsByGroup ¶
func (s *PostgresStore) ListJobsByGroup( ctx context.Context, groupID string, statuses ...JobStatus, ) ([]*Job, error)
ListJobsByGroup retrieves jobs for a group, optionally filtered by status.
func (*PostgresStore) ListJobsByStatus ¶
func (s *PostgresStore) ListJobsByStatus(ctx context.Context, statuses ...JobStatus) ([]*Job, error)
ListJobsByStatus retrieves all jobs with the given statuses.
func (*PostgresStore) ListRunners ¶
func (s *PostgresStore) ListRunners(ctx context.Context) ([]*Runner, error)
ListRunners retrieves all runners.
func (*PostgresStore) ListRunnersByLabels ¶
func (s *PostgresStore) ListRunnersByLabels(ctx context.Context, labels []string) ([]*Runner, error)
ListRunnersByLabels retrieves runners that have all the specified labels.
func (*PostgresStore) Migrate ¶
func (s *PostgresStore) Migrate(ctx context.Context) error
Migrate runs database migrations.
func (*PostgresStore) Ping ¶
func (s *PostgresStore) Ping(ctx context.Context) error
Ping checks database connectivity.
func (*PostgresStore) ReorderJobs ¶
ReorderJobs updates job positions based on the provided order.
func (*PostgresStore) Start ¶
func (s *PostgresStore) Start(ctx context.Context) error
Start opens the database connection.
func (*PostgresStore) Stop ¶
func (s *PostgresStore) Stop() error
Stop closes the database connection.
func (*PostgresStore) UpdateGroup ¶
func (s *PostgresStore) UpdateGroup(ctx context.Context, group *Group) error
UpdateGroup updates an existing group.
func (*PostgresStore) UpdateJob ¶
func (s *PostgresStore) UpdateJob(ctx context.Context, job *Job) error
UpdateJob updates an existing job.
func (*PostgresStore) UpdateJobTemplate ¶
func (s *PostgresStore) UpdateJobTemplate(ctx context.Context, template *JobTemplate) error
UpdateJobTemplate updates an existing job template.
func (*PostgresStore) UpdateTemplateInConfig ¶
UpdateTemplateInConfig updates the in_config status of a job template.
func (*PostgresStore) UpdateUser ¶
func (s *PostgresStore) UpdateUser(ctx context.Context, user *User) error
UpdateUser updates an existing user.
func (*PostgresStore) UpsertRunner ¶
func (s *PostgresStore) UpsertRunner(ctx context.Context, runner *Runner) error
UpsertRunner creates or updates a runner.
type Runner ¶
type Runner struct {
ID int64 `json:"id"`
Name string `json:"name"`
Labels []string `json:"labels"`
Status RunnerStatus `json:"status"`
Busy bool `json:"busy"`
OS string `json:"os"`
LastSeenAt time.Time `json:"last_seen_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Runner represents a GitHub Actions runner.
type RunnerStatus ¶
type RunnerStatus string
RunnerStatus represents the status of a GitHub Actions runner.
const ( RunnerStatusOnline RunnerStatus = "online" RunnerStatusOffline RunnerStatus = "offline" )
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store using SQLite.
func (*SQLiteStore) CreateAuditEntry ¶
func (s *SQLiteStore) CreateAuditEntry(ctx context.Context, entry *AuditEntry) error
CreateAuditEntry creates a new audit log entry.
func (*SQLiteStore) CreateAuthCode ¶
func (s *SQLiteStore) CreateAuthCode(ctx context.Context, code *AuthCode) error
CreateAuthCode creates a new one-time auth code for token exchange.
func (*SQLiteStore) CreateGroup ¶
func (s *SQLiteStore) CreateGroup(ctx context.Context, group *Group) error
CreateGroup creates a new group.
func (*SQLiteStore) CreateJob ¶
func (s *SQLiteStore) CreateJob(ctx context.Context, job *Job) error
CreateJob creates a new job.
func (*SQLiteStore) CreateJobTemplate ¶
func (s *SQLiteStore) CreateJobTemplate(ctx context.Context, template *JobTemplate) error
CreateJobTemplate creates a new job template.
func (*SQLiteStore) CreateOAuthState ¶
func (s *SQLiteStore) CreateOAuthState(ctx context.Context, state *OAuthState) error
CreateOAuthState creates a new OAuth state for CSRF protection.
func (*SQLiteStore) CreateSession ¶
func (s *SQLiteStore) CreateSession(ctx context.Context, session *Session) error
CreateSession creates a new session.
func (*SQLiteStore) CreateUser ¶
func (s *SQLiteStore) CreateUser(ctx context.Context, user *User) error
CreateUser creates a new user.
func (*SQLiteStore) DeleteAuthCode ¶
func (s *SQLiteStore) DeleteAuthCode(ctx context.Context, code string) error
DeleteAuthCode deletes an auth code.
func (*SQLiteStore) DeleteExpiredAuthCodes ¶
func (s *SQLiteStore) DeleteExpiredAuthCodes(ctx context.Context) error
DeleteExpiredAuthCodes deletes all expired auth codes.
func (*SQLiteStore) DeleteExpiredOAuthStates ¶
func (s *SQLiteStore) DeleteExpiredOAuthStates(ctx context.Context) error
DeleteExpiredOAuthStates deletes all expired OAuth states.
func (*SQLiteStore) DeleteExpiredSessions ¶
func (s *SQLiteStore) DeleteExpiredSessions(ctx context.Context) error
DeleteExpiredSessions deletes all expired sessions.
func (*SQLiteStore) DeleteGroup ¶
func (s *SQLiteStore) DeleteGroup(ctx context.Context, id string) error
DeleteGroup deletes a group by ID.
func (*SQLiteStore) DeleteJob ¶
func (s *SQLiteStore) DeleteJob(ctx context.Context, id string) error
DeleteJob deletes a job by ID.
func (*SQLiteStore) DeleteJobTemplate ¶
func (s *SQLiteStore) DeleteJobTemplate(ctx context.Context, id string) error
DeleteJobTemplate deletes a job template by ID.
func (*SQLiteStore) DeleteJobTemplatesByGroup ¶
func (s *SQLiteStore) DeleteJobTemplatesByGroup(ctx context.Context, groupID string) error
DeleteJobTemplatesByGroup deletes all job templates for a group.
func (*SQLiteStore) DeleteOAuthState ¶
func (s *SQLiteStore) DeleteOAuthState(ctx context.Context, state string) error
DeleteOAuthState deletes an OAuth state.
func (*SQLiteStore) DeleteOldJobs ¶
DeleteOldJobs deletes completed, failed, or cancelled jobs older than the given time.
func (*SQLiteStore) DeleteRunner ¶
func (s *SQLiteStore) DeleteRunner(ctx context.Context, id int64) error
DeleteRunner deletes a runner by ID.
func (*SQLiteStore) DeleteSession ¶
func (s *SQLiteStore) DeleteSession(ctx context.Context, id string) error
DeleteSession deletes a session by ID.
func (*SQLiteStore) DeleteStaleRunners ¶
DeleteStaleRunners deletes runners not seen since the given time.
func (*SQLiteStore) DeleteUser ¶
func (s *SQLiteStore) DeleteUser(ctx context.Context, id string) error
DeleteUser deletes a user by ID.
func (*SQLiteStore) DeleteUserSessions ¶
func (s *SQLiteStore) DeleteUserSessions(ctx context.Context, userID string) error
DeleteUserSessions deletes all sessions for a user.
func (*SQLiteStore) GetAuthCode ¶
GetAuthCode retrieves an auth code by its value.
func (*SQLiteStore) GetHistoryStats ¶
func (s *SQLiteStore) GetHistoryStats(ctx context.Context, opts HistoryStatsOpts) (*HistoryStatsResult, error)
GetHistoryStats retrieves aggregated job statistics for a time range.
func (*SQLiteStore) GetHistoryTimeBounds ¶
func (s *SQLiteStore) GetHistoryTimeBounds(ctx context.Context, groupID string) (oldest, newest *time.Time, err error)
GetHistoryTimeBounds returns the oldest and newest completed_at times for history jobs.
func (*SQLiteStore) GetJobTemplate ¶
func (s *SQLiteStore) GetJobTemplate(ctx context.Context, id string) (*JobTemplate, error)
GetJobTemplate retrieves a job template by ID.
func (*SQLiteStore) GetMaxPosition ¶
GetMaxPosition returns the maximum position for jobs in a group.
func (*SQLiteStore) GetNextPendingJob ¶
GetNextPendingJob retrieves the next pending job for a group (lowest position). Paused jobs are excluded from selection.
func (*SQLiteStore) GetOAuthState ¶
func (s *SQLiteStore) GetOAuthState(ctx context.Context, state string) (*OAuthState, error)
GetOAuthState retrieves an OAuth state by its value.
func (*SQLiteStore) GetRunnerByName ¶
GetRunnerByName retrieves a runner by name.
func (*SQLiteStore) GetSession ¶
GetSession retrieves a session by ID.
func (*SQLiteStore) GetSessionByToken ¶
GetSessionByToken retrieves a session by token hash.
func (*SQLiteStore) GetUserByGitHubID ¶
GetUserByGitHubID retrieves a user by GitHub ID.
func (*SQLiteStore) GetUserByUsername ¶
GetUserByUsername retrieves a user by username.
func (*SQLiteStore) HasAnyJobs ¶
HasAnyJobs checks if a template has any jobs (regardless of status).
func (*SQLiteStore) ListAuditEntries ¶
func (s *SQLiteStore) ListAuditEntries( ctx context.Context, opts AuditQueryOpts, ) ([]*AuditEntry, int, error)
ListAuditEntries retrieves audit entries with filtering and pagination.
func (*SQLiteStore) ListGroups ¶
func (s *SQLiteStore) ListGroups(ctx context.Context) ([]*Group, error)
ListGroups retrieves all groups.
func (*SQLiteStore) ListJobHistory ¶
func (s *SQLiteStore) ListJobHistory(ctx context.Context, opts HistoryQueryOpts) (*HistoryResult, error)
ListJobHistory retrieves paginated job history with cursor-based pagination.
func (*SQLiteStore) ListJobTemplatesByGroup ¶
func (s *SQLiteStore) ListJobTemplatesByGroup(ctx context.Context, groupID string) ([]*JobTemplate, error)
ListJobTemplatesByGroup retrieves all job templates for a group.
func (*SQLiteStore) ListJobsByGroup ¶
func (s *SQLiteStore) ListJobsByGroup( ctx context.Context, groupID string, statuses ...JobStatus, ) ([]*Job, error)
ListJobsByGroup retrieves jobs for a group, optionally filtered by status.
func (*SQLiteStore) ListJobsByStatus ¶
ListJobsByStatus retrieves all jobs with the given statuses.
func (*SQLiteStore) ListRunners ¶
func (s *SQLiteStore) ListRunners(ctx context.Context) ([]*Runner, error)
ListRunners retrieves all runners.
func (*SQLiteStore) ListRunnersByLabels ¶
ListRunnersByLabels retrieves runners that have all the specified labels.
func (*SQLiteStore) Migrate ¶
func (s *SQLiteStore) Migrate(ctx context.Context) error
Migrate runs database migrations.
func (*SQLiteStore) Ping ¶
func (s *SQLiteStore) Ping(ctx context.Context) error
Ping checks database connectivity.
func (*SQLiteStore) ReorderJobs ¶
ReorderJobs updates job positions based on the provided order.
func (*SQLiteStore) Start ¶
func (s *SQLiteStore) Start(ctx context.Context) error
Start opens the database connection.
func (*SQLiteStore) UpdateGroup ¶
func (s *SQLiteStore) UpdateGroup(ctx context.Context, group *Group) error
UpdateGroup updates an existing group.
func (*SQLiteStore) UpdateJob ¶
func (s *SQLiteStore) UpdateJob(ctx context.Context, job *Job) error
UpdateJob updates an existing job.
func (*SQLiteStore) UpdateJobTemplate ¶
func (s *SQLiteStore) UpdateJobTemplate(ctx context.Context, template *JobTemplate) error
UpdateJobTemplate updates an existing job template.
func (*SQLiteStore) UpdateTemplateInConfig ¶
UpdateTemplateInConfig updates the in_config status of a job template.
func (*SQLiteStore) UpdateUser ¶
func (s *SQLiteStore) UpdateUser(ctx context.Context, user *User) error
UpdateUser updates an existing user.
func (*SQLiteStore) UpsertRunner ¶
func (s *SQLiteStore) UpsertRunner(ctx context.Context, runner *Runner) error
UpsertRunner creates or updates a runner.
type Session ¶
type Session struct {
ID string `json:"id"`
UserID string `json:"user_id"`
TokenHash string `json:"-"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
Session represents an active user session.
type Store ¶
type Store interface {
// Lifecycle.
Start(ctx context.Context) error
Stop() error
// Health check.
Ping(ctx context.Context) error
// Groups.
CreateGroup(ctx context.Context, group *Group) error
GetGroup(ctx context.Context, id string) (*Group, error)
ListGroups(ctx context.Context) ([]*Group, error)
UpdateGroup(ctx context.Context, group *Group) error
DeleteGroup(ctx context.Context, id string) error
// Job Templates.
CreateJobTemplate(ctx context.Context, template *JobTemplate) error
GetJobTemplate(ctx context.Context, id string) (*JobTemplate, error)
ListJobTemplatesByGroup(ctx context.Context, groupID string) ([]*JobTemplate, error)
UpdateJobTemplate(ctx context.Context, template *JobTemplate) error
DeleteJobTemplate(ctx context.Context, id string) error
DeleteJobTemplatesByGroup(ctx context.Context, groupID string) error
UpdateTemplateInConfig(ctx context.Context, id string, inConfig bool) error
HasAnyJobs(ctx context.Context, templateID string) (bool, error)
// Jobs.
CreateJob(ctx context.Context, job *Job) error
GetJob(ctx context.Context, id string) (*Job, error)
ListJobsByGroup(ctx context.Context, groupID string, statuses ...JobStatus) ([]*Job, error)
ListJobsByStatus(ctx context.Context, statuses ...JobStatus) ([]*Job, error)
ListJobHistory(ctx context.Context, opts HistoryQueryOpts) (*HistoryResult, error)
GetHistoryStats(ctx context.Context, opts HistoryStatsOpts) (*HistoryStatsResult, error)
GetHistoryTimeBounds(ctx context.Context, groupID string) (oldest, newest *time.Time, err error)
UpdateJob(ctx context.Context, job *Job) error
DeleteJob(ctx context.Context, id string) error
DeleteOldJobs(ctx context.Context, olderThan time.Time) (int64, error)
ReorderJobs(ctx context.Context, groupID string, jobIDs []string) error
GetNextPendingJob(ctx context.Context, groupID string) (*Job, error)
GetMaxPosition(ctx context.Context, groupID string) (int, error)
// Runners.
UpsertRunner(ctx context.Context, runner *Runner) error
GetRunner(ctx context.Context, id int64) (*Runner, error)
GetRunnerByName(ctx context.Context, name string) (*Runner, error)
ListRunners(ctx context.Context) ([]*Runner, error)
ListRunnersByLabels(ctx context.Context, labels []string) ([]*Runner, error)
DeleteRunner(ctx context.Context, id int64) error
DeleteStaleRunners(ctx context.Context, olderThan time.Time) error
// Users.
CreateUser(ctx context.Context, user *User) error
GetUser(ctx context.Context, id string) (*User, error)
GetUserByUsername(ctx context.Context, username string) (*User, error)
GetUserByGitHubID(ctx context.Context, githubID string) (*User, error)
UpdateUser(ctx context.Context, user *User) error
DeleteUser(ctx context.Context, id string) error
// Sessions.
CreateSession(ctx context.Context, session *Session) error
GetSession(ctx context.Context, id string) (*Session, error)
GetSessionByToken(ctx context.Context, tokenHash string) (*Session, error)
DeleteSession(ctx context.Context, id string) error
DeleteExpiredSessions(ctx context.Context) error
DeleteUserSessions(ctx context.Context, userID string) error
// OAuth States (CSRF protection).
CreateOAuthState(ctx context.Context, state *OAuthState) error
GetOAuthState(ctx context.Context, state string) (*OAuthState, error)
DeleteOAuthState(ctx context.Context, state string) error
DeleteExpiredOAuthStates(ctx context.Context) error
// Auth Codes (one-time exchange codes).
CreateAuthCode(ctx context.Context, code *AuthCode) error
GetAuthCode(ctx context.Context, code string) (*AuthCode, error)
DeleteAuthCode(ctx context.Context, code string) error
DeleteExpiredAuthCodes(ctx context.Context) error
// Audit.
CreateAuditEntry(ctx context.Context, entry *AuditEntry) error
ListAuditEntries(ctx context.Context, opts AuditQueryOpts) ([]*AuditEntry, int, error)
// Migrations.
Migrate(ctx context.Context) error
}
Store defines the interface for database operations.
func NewPostgresStore ¶
func NewPostgresStore(log logrus.FieldLogger, dsn string) Store
NewPostgresStore creates a new PostgreSQL store.
func NewSQLiteStore ¶
func NewSQLiteStore(log logrus.FieldLogger, path string) Store
NewSQLiteStore creates a new SQLite store.
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
PasswordHash string `json:"-"`
Role Role `json:"role"`
AuthProvider AuthProvider `json:"auth_provider"`
GitHubID string `json:"github_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a user account.