status

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package status handles status spec loading, validation, and resolution.

Index

Constants

This section is empty.

Variables

View Source
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

func Save

func Save(path string, s *Spec) error

Save writes a Spec to disk as YAML.

func Validate

func Validate(s *Spec) error

Validate checks that a Spec has all required fields and is well-formed.

Types

type CheckRunner

type CheckRunner interface {
	RunCheck(ctx context.Context, command string, env []string) bool
}

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"`
	Check       string `yaml:"check,omitempty"`
	Default     bool   `yaml:"default,omitempty"`
}

Entry defines a single status in the spec.

type RepoInfo

type RepoInfo struct {
	URL    string
	Branch string
	Path   string
}

RepoInfo provides context for running status checks against a repo.

type RepoResult

type RepoResult struct {
	URL    string
	Branch string
	Status string
}

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 ShellRunner

type ShellRunner struct{}

ShellRunner executes check commands via sh -c.

func (*ShellRunner) RunCheck

func (r *ShellRunner) RunCheck(ctx context.Context, command string, env []string) bool

RunCheck executes the command in a shell. Returns true if exit code is 0.

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.

func Load

func Load(path string) (*Spec, error)

Load reads and parses a status spec file from disk.

func LoadWithFallback

func LoadWithFallback(workspacePath, globalPath string) (*Spec, error)

LoadWithFallback loads a workspace-level spec if it exists, otherwise falls back to the global spec. Returns ErrSpecNotFound if neither exists.

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
	Repos         []RepoResult
}

WorkspaceResult holds the resolved status for a workspace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL