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 LocalImage ¶ added in v0.170.0
LocalImage reports whether the local Docker daemon holds ref. No daemon, or no docker, is a no.
func LookInDaemon ¶ added in v0.188.0
LookInDaemon asks the local Docker daemon whether it holds ref, and says whether any daemon answered. With docker on PATH the CLI asks, so its context and DOCKER_HOST apply. Without it the daemon's API is asked on its socket, the way Trivy reads an image from a daemon in a container with the socket mounted and no docker CLI installed.
reachable is false only when no daemon answered where one is looked for. A daemon that cannot be asked from here, such as one behind TLS with no docker CLI to hold its certificates, counts as reachable, so a refusal is never blamed on a daemon that may well be there.
Types ¶
type Check ¶
type Check struct {
// Kind is what was checked: repository, paths, image, host, cluster or account.
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.
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)
// Cluster resolves a kubeconfig context, "" for the current one, asks its API server for its
// version, and says what answered.
Cluster func(ctx context.Context, kubeContext string) (string, error)
// Account asks a cloud whether the credentials in the environment can read an account, and
// says what answered.
Account func(ctx context.Context, provider, id string) (string, error)
}
Probes are the checks themselves. A nil field is the real probe; tests replace them.