Documentation
¶
Overview ¶
Package cmd implements the fleetsweeper command line interface on top of cobra.
Index ¶
Constants ¶
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 ¶
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).
Source Files
¶
- cmd_apikey.go
- cmd_backup.go
- cmd_baseline.go
- cmd_compare.go
- cmd_diagnose.go
- cmd_doctor.go
- cmd_drift.go
- cmd_export.go
- cmd_group.go
- cmd_history.go
- cmd_init.go
- cmd_location.go
- cmd_migrate.go
- cmd_recommend.go
- cmd_remediate.go
- cmd_root.go
- cmd_scan.go
- cmd_serve.go
- cmd_tag.go
- cmd_textfile.go
- cmd_top.go
- cmd_verify.go
- cmd_watch.go
- cmd_whatchanged.go
- cmd_whatif.go
- cmd_why.go
- codes.go
- config_file.go
- context.go
- errors.go
- execute.go
- flagcheck.go
- store.go
- version.go