Documentation
¶
Overview ¶
Package status handles status spec loading, validation, and resolution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAPIVersion = errors.New("apiVersion must be flow/v1") ErrInvalidKind = errors.New("kind must be Status") ErrNoStatuses = errors.New("statuses must not be empty") ErrNoDefault = errors.New("exactly one status must have default: true") ErrMultipleDefaults = errors.New("only one status may have default: true") ErrDuplicateName = errors.New("status names must be unique") ErrMissingName = errors.New("status name is required") ErrMissingCheck = errors.New("non-default status must have a check command") ErrSpecNotFound = errors.New("no status spec found") )
Validation errors for status spec files.
Functions ¶
Types ¶
type CheckRunner ¶
CheckRunner executes a status check command and returns whether it matched.
type Entry ¶
type Entry struct {
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Color string `yaml:"color,omitempty"`
Check string `yaml:"check,omitempty"`
Default bool `yaml:"default,omitempty"`
}
Entry defines a single status in the spec.
type RepoResult ¶
RepoResult holds the resolved status for a single repo.
type Resolver ¶
type Resolver struct {
Runner CheckRunner
}
Resolver resolves workspace statuses using a CheckRunner.
func (*Resolver) ResolveRepo ¶
func (r *Resolver) ResolveRepo(ctx context.Context, spec *Spec, repo RepoInfo, wsID, wsName string) string
ResolveRepo determines the status of a single repo by evaluating checks in order. Returns the name of the first matching status or the default.
func (*Resolver) ResolveWorkspace ¶
func (r *Resolver) ResolveWorkspace(ctx context.Context, spec *Spec, repos []RepoInfo, wsID, wsName string) *WorkspaceResult
ResolveWorkspace resolves the status for each repo concurrently and returns the aggregated workspace result. The workspace status is the least-advanced status (highest index in spec order) across all repos.
type Spec ¶
type Spec struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Spec SpecBody `yaml:"spec,omitempty"`
}
Spec represents a status spec file.
func DefaultSpec ¶
func DefaultSpec() *Spec
DefaultSpec returns a starter status spec with a basic PR workflow.
Status checks are evaluated top-to-bottom per repo; first match wins. The workspace-level status is the least-advanced (highest index) across repos.
Default statuses:
closed — a merged PR exists and no open PRs remain (requires gh) stale — no commits on the branch in the last 14 days (local git only) in-review — a non-draft open PR exists on the branch (requires gh) in-progress — uncommitted changes, unpushed commits, or a draft PR open — default; none of the above matched
func LoadWithFallback ¶
LoadWithFallback loads a workspace-level spec if it exists, otherwise falls back to the global spec. Returns ErrSpecNotFound if neither exists.
func (*Spec) DisplayOrder ¶ added in v1.4.0
DisplayOrder returns a map of status name to display sort index. The default (least-advanced) status gets index 0, most-advanced gets the highest.
type SpecBody ¶
type SpecBody struct {
Statuses []Entry `yaml:"statuses,omitempty"`
}
SpecBody holds the statuses list nested under spec.
type WorkspaceResult ¶
type WorkspaceResult struct {
WorkspaceID string
WorkspaceName string
Status string
Duration time.Duration
Repos []RepoResult
}
WorkspaceResult holds the resolved status for a workspace.