check

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryEnvironment  = "environment"
	CategoryQuality      = "quality"
	CategoryArchitecture = "architecture"
	CategorySecurity     = "security"
	CategoryDependencies = "dependencies"
	CategoryTests        = "tests"
)

Category constants for filtering

Variables

AllCategories lists all valid category names

Functions

func ValidateCategories

func ValidateCategories(categories []string) error

ValidateCategories checks if all provided categories are valid

Types

type CheckJSONItem

type CheckJSONItem struct {
	Name       string `json:"name"`
	Category   string `json:"category"`
	Passed     bool   `json:"passed"`
	DurationMs int64  `json:"duration_ms"`
	Error      string `json:"error,omitempty"`
}

CheckJSONItem represents a single check result in JSON output.

type CheckJSONResult

type CheckJSONResult struct {
	Passed bool            `json:"passed"`
	Total  int             `json:"total"`
	Failed int             `json:"failed"`
	Checks []CheckJSONItem `json:"checks"`
}

CheckJSONResult represents the full check output in JSON mode. Implements output.JSONResponder for custom JSON envelope data.

func (CheckJSONResult) JSONResponse

func (r CheckJSONResult) JSONResponse() interface{}

JSONResponse implements output.JSONResponder.

type Config

type Config struct {
	FailFast   bool
	Verbose    bool
	Parallel   bool
	Categories []string // Filter to specific categories (empty = all)
	ShowTiming bool     // Show duration for each check
	BinaryName string   // Binary name for license-binary check (e.g., "myapp")
}

Config holds configuration for the check command

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs checks with a Bubble Tea progress UI or simple output.

func NewExecutor

func NewExecutor(cfg Config, writer io.Writer) *Executor

NewExecutor creates a new executor with TUI or simple output based on environment.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context) error

Execute runs all checks with TUI progress display or simple output.

type OnCheckDone

type OnCheckDone func(index int, result Result)

OnCheckDone is called after each check completes, allowing the caller to update a TUI, log progress, etc. The index is the position within the current category's check list.

type Result

type Result struct {
	Name        string
	Category    string
	Passed      bool
	Duration    time.Duration
	Err         error
	Remediation string
}

Result holds the outcome of a single check execution.

type RunOptions

type RunOptions struct {
	FailFast bool
	Parallel bool
}

RunOptions configures how the Runner executes checks.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner handles check orchestration: filtering, ordering, execution, and result collection. It contains no TUI or rendering logic.

func NewRunner

func NewRunner(timings *timingHistory) *Runner

NewRunner creates a Runner with the given timing history.

func (*Runner) FilterCategories

func (r *Runner) FilterCategories(categories []categoryDef, filters []string) []categoryDef

FilterCategories returns only the categories whose display name matches one of the requested filter names. If filters is empty, all categories are returned.

func (*Runner) RecordTiming

func (r *Runner) RecordTiming(name string, duration time.Duration)

RecordTiming exposes timing recording for callers that need to record durations outside of RunChecks (e.g., TUI mode with its own execution loop).

func (*Runner) RunChecks

func (r *Runner) RunChecks(ctx context.Context, category categoryDef, opts RunOptions, onDone OnCheckDone) ([]Result, error)

RunChecks executes checks sequentially or in parallel, collecting results. It calls onDone (if non-nil) after each check completes. Returns all results and an error if any check failed.

func (*Runner) SaveTimings

func (r *Runner) SaveTimings()

SaveTimings persists timing history to disk.

Jump to

Keyboard shortcuts

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