Documentation
¶
Overview ¶
Package lifecyclehooks runs trusted user-configured commands after WB changes a repository checkout. It is intentionally separate from package hooks, which manages Git's own hook shims and repository policy.
Index ¶
- Constants
- func RepositoryIdentity(checkout string) (string, error)
- type Binding
- type CheckReport
- type Config
- type Dispatcher
- func (dispatcher Dispatcher) Check() (CheckReport, error)
- func (dispatcher Dispatcher) Dispatch(_ context.Context, events []Event) (Report, error)
- func (dispatcher Dispatcher) Drain(ctx context.Context, parallel int) (report Report, returnErr error)
- func (dispatcher Dispatcher) GC(options GCOptions) (GCReport, error)
- func (dispatcher Dispatcher) Plan(events []Event) ([]Planned, Report, error)
- func (dispatcher Dispatcher) Resume() (ResumeReport, error)
- func (dispatcher Dispatcher) Retry(receiptID string) (Report, error)
- func (dispatcher Dispatcher) Status(limit int) (Status, error)
- type Event
- type Executor
- type ExecutorCheck
- type GCOptions
- type GCReport
- type Invocation
- type Match
- type Planned
- type Queued
- type Receipt
- type Report
- type RepositoryMatch
- type ResumeReport
- type Status
- type WorkerHealth
- type WorkerRequest
Constants ¶
const ( ConfigVersion = 1 EventCheckoutUpdated = "checkout-updated" )
Variables ¶
This section is empty.
Functions ¶
func RepositoryIdentity ¶
Types ¶
type CheckReport ¶ added in v0.128.0
type CheckReport struct {
ConfigPath string `json:"config_path"`
Configured bool `json:"configured"`
Executors []ExecutorCheck `json:"executors,omitempty"`
Findings []string `json:"findings,omitempty"`
}
type Config ¶
type Dispatcher ¶
type Dispatcher struct {
ConfigPath string
StateDir string
ReceiptPath string
Now func() time.Time
Run func(context.Context, Invocation) error
EvalSymlinks func(string) (string, error)
LaunchWorker func(WorkerRequest) error
VerifyCheckout func(Event) (string, os.FileInfo, error)
}
func DefaultDispatcher ¶
func DefaultDispatcher() Dispatcher
func (Dispatcher) Check ¶ added in v0.128.0
func (dispatcher Dispatcher) Check() (CheckReport, error)
func (Dispatcher) Dispatch ¶
Dispatch durably enqueues matching events and returns without waiting for external executors. A detached worker is only a wake-up mechanism: queued state remains authoritative if the worker cannot start or is interrupted.
func (Dispatcher) Drain ¶ added in v0.128.0
func (dispatcher Dispatcher) Drain(ctx context.Context, parallel int) (report Report, returnErr error)
Drain executes durable queue entries with bounded concurrency. Only one worker owns a state directory; enqueue uses a separate short-lived lock and therefore never waits for an external command to finish.
func (Dispatcher) GC ¶ added in v0.128.0
func (dispatcher Dispatcher) GC(options GCOptions) (GCReport, error)
func (Dispatcher) Plan ¶ added in v0.128.0
func (dispatcher Dispatcher) Plan(events []Event) ([]Planned, Report, error)
Plan reports the executor/checkouts that an event set would enqueue without mutating queue state or starting a worker.
func (Dispatcher) Resume ¶ added in v0.128.0
func (dispatcher Dispatcher) Resume() (ResumeReport, error)
type ExecutorCheck ¶ added in v0.128.0
type Invocation ¶
type Match ¶
type Match struct {
Repositories RepositoryMatch `yaml:"repositories"`
}
type Receipt ¶ added in v0.128.0
type Receipt struct {
SchemaVersion int `json:"schema_version"`
ID string `json:"id"`
Event string `json:"event"`
Repository string `json:"repository"`
Checkout string `json:"checkout"`
OldSHA string `json:"old_sha,omitempty"`
NewSHA string `json:"new_sha"`
Cause string `json:"cause"`
OperationID string `json:"operation_id,omitempty"`
Executor string `json:"executor"`
CoalescedCount int `json:"coalesced_count,omitempty"`
QueuedAt time.Time `json:"queued_at"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
DurationMS int64 `json:"duration_ms"`
Status string `json:"status"`
Failure string `json:"failure,omitempty"`
Message string `json:"message,omitempty"`
StdoutPath string `json:"stdout_path,omitempty"`
StderrPath string `json:"stderr_path,omitempty"`
StdoutTruncated bool `json:"stdout_truncated,omitempty"`
StderrTruncated bool `json:"stderr_truncated,omitempty"`
}
Receipt is the private local audit record for one terminal hook attempt. Command output stays in bounded 0600 diagnostic files and is never copied into the receipt or normal WB output.
type Report ¶
type RepositoryMatch ¶
type ResumeReport ¶ added in v0.128.0
type Status ¶ added in v0.128.0
type Status struct {
StateDir string `json:"state_dir"`
ReceiptPath string `json:"receipt_path"`
Worker string `json:"worker"`
WorkerHealth *WorkerHealth `json:"worker_health,omitempty"`
UnseenFailures int `json:"unseen_failures"`
Quarantined int `json:"quarantined"`
Pending []Queued `json:"pending"`
Running []Queued `json:"running"`
Receipts []Receipt `json:"receipts"`
Findings []string `json:"findings,omitempty"`
}