engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset    = "\033[0m"
	Red      = "\033[31m"
	Green    = "\033[32m"
	Yellow   = "\033[33m"
	Cyan     = "\033[36m"
	CyanBold = "\033[1;36m"
)

ANSI color codes used by renderText.

Variables

View Source
var ErrCheckFailed = errors.New("one or more blocker checks failed")

ErrCheckFailed is returned by Run when one or more blocker-severity checks fail. Callers use errors.Is to distinguish this from unexpected internal errors.

Functions

func Colorize

func Colorize(code, text string) string

Colorize is the exported form of colorize for use outside this package.

func Run

func Run(cfg *model.PrebootConfig, opts RunOptions) error

Run executes all configured checks and renders a report. It returns nil when the environment is healthy, or ErrCheckFailed when any blocker (or warning in strict mode) fails.

Types

type CheckResult

type CheckResult struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Severity string `json:"severity"`
	Status   string `json:"status"`
	Reason   string `json:"reason,omitempty"`
	Message  string `json:"message,omitempty"`
	Fix      string `json:"fix,omitempty"`
}

CheckResult holds the outcome of a single check execution. Status is one of "pass", "fail", or "skipped".

type RunOptions

type RunOptions struct {
	// QuickMode skips network checks (http_reachable, tcp_reachable).
	QuickMode bool
	// Format is "text" (default) or "json". Any other value is treated as "text".
	Format string
	// Stdout receives the report (check results + summary in text mode; JSON object in json mode).
	// Defaults to os.Stdout when nil.
	Stdout io.Writer
	// Stderr receives progress lines ("Running Preboot Diagnostics...") and warnings.
	// Defaults to os.Stderr when nil.
	Stderr io.Writer
	// Ctx is the parent context. When nil, Run creates one wired to SIGINT/SIGTERM so
	// Ctrl-C cancels in-flight HTTP/TCP checks cleanly.
	Ctx context.Context
}

RunOptions controls Run behaviour. Zero value runs in text mode writing to os.Stdout/os.Stderr with no quick-mode filtering.

type RunReport

type RunReport struct {
	Passed        int           `json:"passed"`
	Failed        int           `json:"failed"`
	BlockerFailed bool          `json:"blocker_failed"`
	Checks        []CheckResult `json:"checks"`
}

RunReport is the top-level output of a Run() call, suitable for both human rendering and JSON serialization via --format=json.

Jump to

Keyboard shortcuts

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