Help us shape the future of Go! Take the 2026 Go Developer Survey

cmd

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 75 Imported by: 0

Documentation

Overview

Package cmd implements the fleetsweeper command line interface on top of cobra.

Index

Constants

View Source
const (
	// CodeSuccess indicates the command completed successfully.
	CodeSuccess = 0
	// CodeGeneralError indicates an unspecified error.
	CodeGeneralError = 1
	// CodeConnectionError indicates a failure connecting to one or more clusters.
	CodeConnectionError = 2
	// CodeNoContexts indicates no kubeconfig contexts were resolved.
	CodeNoContexts = 3
	// CodeNoDB indicates no store path resolved: no --db and no home directory.
	CodeNoDB = 4
)

Variables

View Source
var (
	// ErrNoClients indicates all cluster connections failed.
	ErrNoClients = errors.New("no clusters reachable")
	// ErrNoDatabase indicates no --db was given and no default state store can be derived.
	ErrNoDatabase = errors.New("no database: pass --db or set HOME")
	// ErrDemoDatabase indicates --demo was given a --db, which would seed the demo fleet into a
	// real database.
	ErrDemoDatabase = errors.New("--demo runs on its own in-memory store and does not take --db")
	// ErrStableScans indicates --admission-stable-scans is below one.
	ErrStableScans = errors.New("--admission-stable-scans must be at least 1")
	// ErrFlagValue indicates a flag was given a value outside its allowed set.
	ErrFlagValue = errors.New("invalid flag value")
	// ErrLogLevel indicates --log-level named an unknown level.
	ErrLogLevel = errors.New("invalid log level")
	// ErrNoScans indicates a command needs a stored scan and the store has none.
	ErrNoScans = errors.New("no scans in store: run fleetsweeper scan --db <dsn> first")
	// ErrTooFewScans indicates a scan reference needs more stored scans than the store holds.
	ErrTooFewScans = errors.New("need at least two scans")
)

Functions

func Execute

func Execute()

Execute runs the root command with a signal-cancellable context and exits with the code its error maps to. SIGINT and SIGTERM both trigger graceful shutdown so containerized deployments behave correctly under Kubernetes pod termination. OpenTelemetry tracing is initialized here when an OTLP endpoint is configured; it is a no-op otherwise.

Types

type CheckResult

type CheckResult struct {
	// Name is the human-readable check identifier.
	Name string `json:"name"`
	// Status is the per-check status.
	Status Status `json:"status"`
	// Detail is a human-readable explanation.
	Detail string `json:"detail,omitempty"`
	// DurationMS is how long the check took.
	DurationMS int64 `json:"duration_ms"`
}

CheckResult is one check's outcome.

type Report

type Report struct {
	// Generated is when the report ran.
	Generated time.Time `json:"generated"`
	// Checks are the individual check outcomes.
	Checks []CheckResult `json:"checks"`
	// Summary tallies the per-status counts.
	Summary map[Status]int `json:"summary"`
}

Report aggregates all the checks for serialized output.

type Status

type Status string

Status enumerates the per-check outcomes the doctor reports.

const (
	// StatusOK indicates the check passed.
	StatusOK Status = "ok"
	// StatusWarn indicates a non-fatal concern.
	StatusWarn Status = "warn"
	// StatusFail indicates a definitive failure.
	StatusFail Status = "fail"
	// StatusSkip indicates the check did not apply (missing input).
	StatusSkip Status = "skip"
)

Doctor status constants. "warn" allows a check to flag a concern that is not a hard failure (for example, the controller CRD is absent because the user hasn't enabled the operator yet).

Jump to

Keyboard shortcuts

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