preflight

package
v0.136.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package preflight checks that this machine can reach what a scan would read: each repository at its revision, the paths a component is scoped to, each image, each endpoint. With the credentials and the network the scan would have, and before the scan is started.

Every check touches something outside the descriptor, a checkout, a registry, a network or a credential, which is why it lives in `doctor` rather than `validate`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FailedCount

func FailedCount(checks []Check) int

FailedCount counts the checks that failed.

Types

type Check

type Check struct {
	// Kind is what was checked: repository, paths, image, host or infrastructure.
	Kind string `json:"kind"`
	// Target names it, without credentials.
	Target string `json:"target"`
	Status Status `json:"status"`
	// Detail is the result in words: what resolved, or why it failed or was not checked.
	Detail string `json:"detail"`
}

Check is one target checked, and what came of it.

func Run

func Run(ctx context.Context, targets []plugin.Target, opts Options) []Check

Run checks every distinct target once, in the order they are first named. Components sharing a repository or an image share its check.

type Options

type Options struct {
	// Offline skips every check that needs the network, and reports each as not checked.
	Offline bool
	// Timeout bounds each target's checks. Zero means 20 seconds.
	Timeout time.Duration
	// Concurrency bounds how many targets are checked at once. Zero means 8.
	Concurrency int
	Probes      Probes
}

Options shape a run.

type Probes

type Probes struct {
	// Revision resolves a repository's revision to a commit.
	Revision func(ctx context.Context, url, revision string) (string, error)
	// Paths checks a repository's paths at a revision and returns the commit it read.
	Paths func(ctx context.Context, url, revision string, paths []string) (string, error)
	// Image checks that an image can be read, and says from where.
	Image func(ctx context.Context, ref string, offline bool) (string, error)
	// Host opens a connection to an endpoint and says what it established.
	Host func(ctx context.Context, rawURL string) (string, error)
}

Probes are the checks themselves. A nil field is the real probe; tests replace them.

type Status

type Status string

Status is how a check ended.

const (
	Passed     Status = "passed"
	Failed     Status = "failed"
	NotChecked Status = "not-checked"
)

The ways a check ends. NotChecked is neither of the others: a check that did not run has not passed, and it has not found anything wrong either.

Jump to

Keyboard shortcuts

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