preflight

package
v0.19.1111 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig() (*internal.Config, error)

LoadConfig loads configuration without running struct validation.

internal.NewConfig would reject a partial config before any check could run, which is the opposite of what preflight is for: each check validates only the fields it needs and reports them by name.

func Names

func Names() []string

func PrintChecks

func PrintChecks(w io.Writer, results []Result)

PrintChecks renders every check, its skip state, and the config it reads. Pair it with Describe to list checks without touching the network.

func PrintResults

func PrintResults(w io.Writer, results []Result) int

PrintResults renders the results table and returns the process exit code. A skipped check is not a failure.

func WriteJSONChecks

func WriteJSONChecks(w io.Writer, results []Result) error

WriteJSONChecks emits the check catalogue as JSON. No summary: nothing ran.

func WriteJSONResults

func WriteJSONResults(w io.Writer, results []Result) int

WriteJSONResults emits a run as JSON and returns the process exit code, using the same rule as the table: only a failure is non-zero.

Types

type Check

type Check struct {
	Name        string
	Description string

	// Skip reports why the check does not apply to this config, e.g. a
	// cloud_provider or feature flag that turns the dependency off.
	Skip func(cfg *internal.Config) (string, bool)

	// Fields is a func rather than a static list so required-ness can depend on
	// other config: db_password is only required when db_use_iam is off.
	Fields func(cfg *internal.Config) []Field

	Probe func(ctx context.Context, cfg *internal.Config) (string, error)
}

Check declares an external dependency, the config it reads, and how to probe it.

func All

func All() []Check

func Lookup

func Lookup(name string) (Check, bool)

type Field

type Field struct {
	Name     string
	Value    string
	Required bool
	Secret   bool
}

Field is one config value a check depends on. Value is pre-rendered by the check so typed fields (bool, time.Duration) format themselves.

func (Field) Display

func (f Field) Display() string

Display renders a field value for output, masking secrets.

type Result

type Result struct {
	Name        string
	Description string
	Status      Status
	Detail      string
	Fields      []Field
}

func Describe

func Describe(cfg *internal.Config, names []string) []Result

Describe evaluates skip state and field values for the named checks without probing anything, backing `preflight --list`.

func Run

func Run(ctx context.Context, cfg *internal.Config, names []string) []Result

Run executes the named checks, or every check in registry order when names is empty. A check is skipped, then field-validated, then probed.

func (Result) Failed

func (r Result) Failed() bool

type Status

type Status string
const (
	StatusPass    Status = "pass"
	StatusWarn    Status = "warn"
	StatusFail    Status = "fail"
	StatusSkipped Status = "skipped"
)

Jump to

Keyboard shortcuts

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