Documentation
¶
Index ¶
- Variables
- func Checkout(repoPath string, event protocol.EventMsg) error
- func CurrentGitState(repoPath string) (string, string, error)
- func EnsureRepo(reposDir, repoName, cloneURL string) (string, error)
- func Run(ctx context.Context, cfg Config)
- func RunHook(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) error
- func RunHookWithOutput(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) (string, error)
- func ShouldNotify(notifyOn []string, state string) bool
- func StartAutoUpdater(ctx context.Context)
- func StartRepoChecker(ctx context.Context, cfg Config)
- func StartWebConsole(ctx context.Context, cfg Config, logStore *ExecutionLog, ...) error
- type ApprovalData
- type ApprovalStore
- func (s *ApprovalStore) ApproveRepo(repo string) error
- func (s *ApprovalStore) ApproveSender(sender string) error
- func (s *ApprovalStore) IsApproved(repo, sender string) bool
- func (s *ApprovalStore) List() string
- func (s *ApprovalStore) RevokeRepo(repo string) error
- func (s *ApprovalStore) RevokeSender(sender string) error
- type Config
- type ConfiguredEvent
- type EventHooks
- type EventicConfig
- type ExecutionEvent
- type ExecutionLog
- func (l *ExecutionLog) AddHook(deliveryID, name, state, output string)
- func (l *ExecutionLog) Events() []ExecutionEvent
- func (l *ExecutionLog) FinishEvent(deliveryID, state, desc string) *ExecutionEvent
- func (l *ExecutionLog) FinishHook(deliveryID, name, state, output string)
- func (l *ExecutionLog) StartEvent(event protocol.EventMsg) ExecutionEvent
- func (l *ExecutionLog) StartHook(deliveryID, name string)
- func (l *ExecutionLog) Subscribe() (<-chan ExecutionEvent, func())
- type HookExecution
- type HookSet
- type ProjectEvent
- type ProjectState
- type ProjectStore
- func (s *ProjectStore) Close() error
- func (s *ProjectStore) FinishProject(ctx context.Context, event ExecutionEvent)
- func (s *ProjectStore) GetProject(ctx context.Context, repo string) (*ProjectState, error)
- func (s *ProjectStore) ListConfiguredEvents(ctx context.Context, repo string) ([]ConfiguredEvent, error)
- func (s *ProjectStore) ListProjectEvents(ctx context.Context, repo string, limit int) ([]ProjectEvent, error)
- func (s *ProjectStore) ListProjects(ctx context.Context) ([]string, error)
- func (s *ProjectStore) PruneProjectEvents(ctx context.Context, repo string, retain int)
- func (s *ProjectStore) RecordProjectEvent(ctx context.Context, event ExecutionEvent)
- func (s *ProjectStore) SeedFromReposDir(ctx context.Context, reposDir string, cfg Config)
- func (s *ProjectStore) StartConfiguredEvent(ctx context.Context, repo string, event protocol.EventMsg, hookName string)
- func (s *ProjectStore) StartProject(ctx context.Context, event ExecutionEvent)
- func (s *ProjectStore) SyncConfiguredEvents(ctx context.Context, repo, repoPath string, cfg Config)
- func (s *ProjectStore) UpdateConfiguredEvent(ctx context.Context, repo string, event protocol.EventMsg, ...)
- func (s *ProjectStore) UpdateGitState(ctx context.Context, repo, ref, hash string)
- func (s *ProjectStore) UpdateOutput(ctx context.Context, repo string, event protocol.EventMsg, ...)
- func (s *ProjectStore) UpsertManagedProject(ctx context.Context, repo, ref, hash string)
- type ReplayDispatcher
- type ReplayRef
- type RepoLocks
- type StateConfig
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
var GitHubWebhookEvents = map[string][]string{
"branch_protection_configuration": {"disabled", "enabled"},
"branch_protection_rule": {"created", "deleted", "edited"},
"check_run": {"completed", "created", "requested_action", "rerequested"},
"check_suite": {"completed", "requested", "rerequested"},
"code_scanning_alert": {"appeared_in_branch", "closed_by_user", "created", "fixed", "reopened", "reopened_by_user"},
"commit_comment": {"created"},
"create": {},
"custom_property": {"created", "deleted", "updated"},
"custom_property_values": {"updated"},
"delete": {},
"dependabot_alert": {"auto_dismissed", "auto_reopened", "created", "dismissed", "fixed", "reintroduced", "reopened"},
"deploy_key": {"created", "deleted"},
"deployment": {"created"},
"deployment_protection_rule": {"requested"},
"deployment_review": {"approved", "rejected", "requested"},
"deployment_status": {"created"},
"discussion": {"answered", "category_changed", "created", "deleted", "edited", "labeled", "locked", "pinned", "transferred", "unanswered", "unlabeled", "unlocked", "unpinned"},
"discussion_comment": {"created", "deleted", "edited"},
"fork": {},
"github_app_authorization": {"revoked"},
"gollum": {},
"installation": {"created", "deleted", "new_permissions_accepted", "suspend", "unsuspend"},
"installation_repositories": {"added", "removed"},
"installation_target": {"renamed"},
"issue_comment": {"created", "deleted", "edited"},
"issues": {"assigned", "closed", "deleted", "demilestoned", "edited", "labeled", "locked", "milestoned", "opened", "pinned", "reopened", "transferred", "unassigned", "unlabeled", "unlocked", "unpinned"},
"label": {"created", "deleted", "edited"},
"marketplace_purchase": {"cancelled", "changed", "pending_change", "pending_change_cancelled", "purchased"},
"member": {"added", "edited", "removed"},
"membership": {"added", "removed"},
"merge_group": {"checks_requested", "destroyed"},
"meta": {"deleted"},
"milestone": {"closed", "created", "deleted", "edited", "opened"},
"org_block": {"blocked", "unblocked"},
"organization": {"deleted", "member_added", "member_invited", "member_removed", "renamed"},
"package": {"published", "updated"},
"page_build": {},
"personal_access_token_request": {"approved", "cancelled", "created", "denied"},
"ping": {},
"project": {"closed", "created", "deleted", "edited", "reopened"},
"project_card": {"converted", "created", "deleted", "edited", "moved"},
"project_column": {"created", "deleted", "edited", "moved"},
"projects_v2": {"closed", "created", "deleted", "edited", "reopened"},
"projects_v2_item": {"archived", "converted", "created", "deleted", "edited", "reordered", "restored"},
"projects_v2_status_update": {"created", "deleted", "edited"},
"public": {},
"pull_request": {"assigned", "auto_merge_disabled", "auto_merge_enabled", "closed", "converted_to_draft", "demilestoned", "dequeued", "edited", "enqueued", "labeled", "locked", "milestoned", "opened", "ready_for_review", "reopened", "review_request_removed", "review_requested", "synchronize", "unassigned", "unlabeled", "unlocked"},
"pull_request_review": {"dismissed", "edited", "submitted"},
"pull_request_review_comment": {"created", "deleted", "edited"},
"pull_request_review_thread": {"resolved", "unresolved"},
"push": {},
"registry_package": {"published", "updated"},
"release": {"created", "deleted", "edited", "prereleased", "published", "released", "unpublished"},
"repository": {"archived", "created", "deleted", "edited", "privatized", "publicized", "renamed", "transferred", "unarchived"},
"repository_advisory": {"published", "reported"},
"repository_dispatch": {},
"repository_import": {},
"repository_ruleset": {"created", "deleted", "edited"},
"repository_vulnerability_alert": {"create", "dismiss", "resolve"},
"secret_scanning_alert": {"created", "resolved", "reopened", "validated"},
"secret_scanning_alert_location": {"created"},
"security_advisory": {"performed", "published", "updated", "withdrawn"},
"security_and_analysis": {},
"sponsorship": {"cancelled", "created", "edited", "pending_cancellation", "pending_tier_change", "tier_changed"},
"star": {"created", "deleted"},
"status": {},
"sub_issues": {"parent_issue_added", "parent_issue_removed", "sub_issue_added", "sub_issue_removed"},
"team": {"added_to_repository", "created", "deleted", "edited", "removed_from_repository"},
"team_add": {},
"watch": {"started"},
"workflow_dispatch": {},
"workflow_job": {"completed", "in_progress", "queued", "waiting"},
"workflow_run": {"completed", "in_progress", "requested"},
}
GitHubWebhookEvents maps each GitHub webhook event type to its known action values. Events with an empty slice have no action field. This reference is provided for users configuring global-ignore-pre / global-ignore-post and global-allowed-pre / global-allowed-post patterns; it is NOT used for runtime validation since GitHub may add new events or actions at any time.
Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads
var Version = "dev"
Version is set at build time via -ldflags "-X main.version=...". It is copied from the main package at startup.
Functions ¶
func CurrentGitState ¶ added in v0.7.0
CurrentGitState returns the checked-out ref name and commit hash for a repo.
func EnsureRepo ¶
EnsureRepo clones the repo if it doesn't exist, or fetches if it does.
func RunHookWithOutput ¶
func RunHookWithOutput(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) (string, error)
RunHookWithOutput executes a hook and returns its combined output.
func ShouldNotify ¶ added in v0.5.0
ShouldNotify checks whether a notification should fire based on the notify_on filter and the current state. An empty filter means always notify.
func StartAutoUpdater ¶ added in v0.2.0
StartAutoUpdater runs a background loop that checks for new releases every 5 minutes. When a newer version is found it replaces the running binary and exits so systemd (or the parent supervisor) can restart the service.
func StartRepoChecker ¶ added in v0.3.0
StartRepoChecker runs a background loop that periodically walks the repos directory and verifies every cloned repository is healthy. Repos that are missing a .git directory or fail a basic git sanity check are re-cloned on the default branch. Repos already checked out on a branch are left as-is.
Repos are checked one at a time to avoid overwhelming the system.
func StartWebConsole ¶ added in v0.6.0
func StartWebConsole(ctx context.Context, cfg Config, logStore *ExecutionLog, projectStore *ProjectStore, replay ReplayDispatcher) error
Types ¶
type ApprovalData ¶ added in v0.5.0
type ApprovalStore ¶ added in v0.5.0
type ApprovalStore struct {
Data ApprovalData
// contains filtered or unexported fields
}
ApprovalStore manages persistent approval of repositories and senders.
func NewApprovalStore ¶ added in v0.5.0
func NewApprovalStore(path string) *ApprovalStore
func (*ApprovalStore) ApproveRepo ¶ added in v0.5.0
func (s *ApprovalStore) ApproveRepo(repo string) error
func (*ApprovalStore) ApproveSender ¶ added in v0.5.0
func (s *ApprovalStore) ApproveSender(sender string) error
func (*ApprovalStore) IsApproved ¶ added in v0.5.0
func (s *ApprovalStore) IsApproved(repo, sender string) bool
func (*ApprovalStore) List ¶ added in v0.5.0
func (s *ApprovalStore) List() string
func (*ApprovalStore) RevokeRepo ¶ added in v0.5.0
func (s *ApprovalStore) RevokeRepo(repo string) error
func (*ApprovalStore) RevokeSender ¶ added in v0.5.0
func (s *ApprovalStore) RevokeSender(sender string) error
type Config ¶
type Config struct {
Relay string `yaml:"relay"`
Token string `yaml:"token"`
ClientID string `yaml:"client_id"`
ReposDir string `yaml:"repos_dir"`
Subscribe []string `yaml:"subscribe"`
AutoUpdate bool `yaml:"auto-update"`
AutoCheck *bool `yaml:"auto-check"`
MaxWorkers int `yaml:"max-workers"`
LogLevel string `yaml:"log-level"`
GlobalHooks struct {
Pre string `yaml:"pre"`
Post string `yaml:"post"`
Notify string `yaml:"notify"`
NotifyOn []string `yaml:"notify_on"`
} `yaml:"global-hooks"`
GlobalIgnorePre []string `yaml:"global-ignore-pre"`
GlobalIgnorePost []string `yaml:"global-ignore-post"`
GlobalAllowedPre []string `yaml:"global-allowed-pre"`
GlobalAllowedPost []string `yaml:"global-allowed-post"`
DefaultNotify string `yaml:"default-notify"`
DefaultNotifyOn []string `yaml:"default-notify-on"`
Notifier notifier.Config `yaml:"notifier"`
RequireApproval bool `yaml:"require_approval"`
ApprovalsPath string `yaml:"approvals_path"`
Web WebConfig `yaml:"web"`
State StateConfig `yaml:"state"`
}
type ConfiguredEvent ¶ added in v0.9.0
type ConfiguredEvent struct {
Repo string `json:"repo"`
EventKey string `json:"event_key"`
Source string `json:"source"`
Hook string `json:"hook"`
Event string `json:"event,omitempty"`
Action string `json:"action,omitempty"`
DeliveryID string `json:"delivery_id,omitempty"`
State string `json:"state"`
LatestOutput string `json:"latest_output"`
Description string `json:"description,omitempty"`
Ref string `json:"ref,omitempty"`
Hash string `json:"hash,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
DurationMillis int64 `json:"duration_ms,omitempty"`
}
ConfiguredEvent is a configured hook slot for a repo, with latest run output.
type EventHooks ¶
type EventHooks struct {
Pre string `yaml:"pre"`
Post string `yaml:"post"`
Notify string `yaml:"notify"`
NotifyOn []string `yaml:"notify_on"` // e.g. ["failure"], ["success", "failure"]
}
EventHooks defines pre/post/notify hooks for a specific event or event.action.
type EventicConfig ¶
type EventicConfig struct {
Hooks struct {
Pre string `yaml:"pre"`
Post string `yaml:"post"`
Notify string `yaml:"notify"`
NotifyOn []string `yaml:"notify_on"`
} `yaml:"hooks"`
Events map[string]EventHooks `yaml:"events"`
}
EventicConfig is the in-repo .eventic.yaml format.
type ExecutionEvent ¶ added in v0.6.0
type ExecutionEvent struct {
ID string `json:"id"`
DeliveryID string `json:"delivery_id"`
Repo string `json:"repo"`
Ref string `json:"ref,omitempty"`
Event string `json:"event"`
Action string `json:"action,omitempty"`
Sender string `json:"sender,omitempty"`
State string `json:"state"`
Description string `json:"description,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
DurationMillis int64 `json:"duration_ms,omitempty"`
Hooks []HookExecution `json:"hooks"`
}
ExecutionEvent is a compact, local-only view of an Eventic event execution.
type ExecutionLog ¶ added in v0.6.0
type ExecutionLog struct {
// contains filtered or unexported fields
}
func NewExecutionLog ¶ added in v0.6.0
func NewExecutionLog(cfg WebConfig) *ExecutionLog
func (*ExecutionLog) AddHook ¶ added in v0.6.0
func (l *ExecutionLog) AddHook(deliveryID, name, state, output string)
func (*ExecutionLog) Events ¶ added in v0.6.0
func (l *ExecutionLog) Events() []ExecutionEvent
func (*ExecutionLog) FinishEvent ¶ added in v0.6.0
func (l *ExecutionLog) FinishEvent(deliveryID, state, desc string) *ExecutionEvent
func (*ExecutionLog) FinishHook ¶ added in v0.6.0
func (l *ExecutionLog) FinishHook(deliveryID, name, state, output string)
func (*ExecutionLog) StartEvent ¶ added in v0.6.0
func (l *ExecutionLog) StartEvent(event protocol.EventMsg) ExecutionEvent
func (*ExecutionLog) StartHook ¶ added in v0.6.0
func (l *ExecutionLog) StartHook(deliveryID, name string)
func (*ExecutionLog) Subscribe ¶ added in v0.6.0
func (l *ExecutionLog) Subscribe() (<-chan ExecutionEvent, func())
type HookExecution ¶ added in v0.6.0
type HookExecution struct {
Name string `json:"name"`
State string `json:"state"`
Output string `json:"output,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
DurationMillis int64 `json:"duration_ms,omitempty"`
}
HookExecution records one local hook run and its bounded combined output.
type HookSet ¶
type HookSet struct {
Pre string // global pre hook — runs for every event
Post string // global post hook — runs for every event
Notify string // global notify template
NotifyOn []string // global notify filter (e.g. ["failure"])
EventPre string // event-specific pre hook
EventPost string // event-specific post hook
EventNotify string // event-specific notify template
EventNotifyOn []string // event-specific notify filter
}
HookSet holds all hooks resolved for a single event.
type ProjectEvent ¶ added in v0.8.0
type ProjectEvent struct {
Repo string `json:"repo"`
DeliveryID string `json:"delivery_id"`
Ref string `json:"ref,omitempty"`
Hash string `json:"hash,omitempty"`
Event string `json:"event,omitempty"`
Action string `json:"action,omitempty"`
State string `json:"state"`
LatestOutput string `json:"latest_output,omitempty"`
Description string `json:"description,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
DurationMillis int64 `json:"duration_ms,omitempty"`
}
ProjectEvent is a bounded persisted execution history item for one repo.
type ProjectState ¶ added in v0.7.0
type ProjectState struct {
Repo string `json:"repo"`
Ref string `json:"ref,omitempty"`
Hash string `json:"hash,omitempty"`
Event string `json:"event,omitempty"`
Action string `json:"action,omitempty"`
DeliveryID string `json:"delivery_id,omitempty"`
State string `json:"state"`
LatestOutput string `json:"latest_output,omitempty"`
Description string `json:"description,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
DurationMillis int64 `json:"duration_ms,omitempty"`
RecentEvents []ProjectEvent `json:"recent_events,omitempty"`
ConfiguredEvents []ConfiguredEvent `json:"configured_events,omitempty"`
}
ProjectState is the persisted latest state for a managed repository.
type ProjectStore ¶ added in v0.7.0
type ProjectStore struct {
// contains filtered or unexported fields
}
func OpenMemoryProjectStore ¶ added in v0.9.0
func OpenMemoryProjectStore(ctx context.Context) (*ProjectStore, error)
func OpenProjectStore ¶ added in v0.7.0
func OpenProjectStore(ctx context.Context, cfg StateConfig) (*ProjectStore, error)
func (*ProjectStore) Close ¶ added in v0.7.0
func (s *ProjectStore) Close() error
func (*ProjectStore) FinishProject ¶ added in v0.7.0
func (s *ProjectStore) FinishProject(ctx context.Context, event ExecutionEvent)
func (*ProjectStore) GetProject ¶ added in v0.7.0
func (s *ProjectStore) GetProject(ctx context.Context, repo string) (*ProjectState, error)
func (*ProjectStore) ListConfiguredEvents ¶ added in v0.9.0
func (s *ProjectStore) ListConfiguredEvents(ctx context.Context, repo string) ([]ConfiguredEvent, error)
func (*ProjectStore) ListProjectEvents ¶ added in v0.8.0
func (s *ProjectStore) ListProjectEvents(ctx context.Context, repo string, limit int) ([]ProjectEvent, error)
func (*ProjectStore) ListProjects ¶ added in v0.7.0
func (s *ProjectStore) ListProjects(ctx context.Context) ([]string, error)
func (*ProjectStore) PruneProjectEvents ¶ added in v0.8.0
func (s *ProjectStore) PruneProjectEvents(ctx context.Context, repo string, retain int)
func (*ProjectStore) RecordProjectEvent ¶ added in v0.8.0
func (s *ProjectStore) RecordProjectEvent(ctx context.Context, event ExecutionEvent)
func (*ProjectStore) SeedFromReposDir ¶ added in v0.7.0
func (s *ProjectStore) SeedFromReposDir(ctx context.Context, reposDir string, cfg Config)
func (*ProjectStore) StartConfiguredEvent ¶ added in v0.11.1
func (*ProjectStore) StartProject ¶ added in v0.7.0
func (s *ProjectStore) StartProject(ctx context.Context, event ExecutionEvent)
func (*ProjectStore) SyncConfiguredEvents ¶ added in v0.9.0
func (s *ProjectStore) SyncConfiguredEvents(ctx context.Context, repo, repoPath string, cfg Config)
func (*ProjectStore) UpdateConfiguredEvent ¶ added in v0.9.0
func (*ProjectStore) UpdateGitState ¶ added in v0.7.0
func (s *ProjectStore) UpdateGitState(ctx context.Context, repo, ref, hash string)
func (*ProjectStore) UpdateOutput ¶ added in v0.7.0
func (*ProjectStore) UpsertManagedProject ¶ added in v0.7.0
func (s *ProjectStore) UpsertManagedProject(ctx context.Context, repo, ref, hash string)
type ReplayDispatcher ¶ added in v0.11.4
type RepoLocks ¶ added in v0.3.0
type RepoLocks struct {
// contains filtered or unexported fields
}
RepoLocks provides per-repository mutual exclusion so that concurrent events targeting the same repo are serialized (queued), while events for different repos run in parallel.
func NewRepoLocks ¶ added in v0.3.0
func NewRepoLocks() *RepoLocks
type StateConfig ¶ added in v0.7.0
StateConfig controls the client-local persistent project database.