diag

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package diag implements `kubetective doctor` (issue #2, v1.0 checklist): a read-only environment preflight. Every check reports OK, WARN, or FAIL with a human fix hint; the command exits non-zero only on failures.

Checks never mutate anything: kubeconfig is loaded read-only, the store is listed read-only, and optional sources (Prometheus, Loki) are probed with a GET only when configured.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name   string `json:"name"`
	Level  Level  `json:"level"`
	Detail string `json:"detail,omitempty"`
}

Check is one doctor finding.

type Level

type Level string

Level of a check result.

const (
	OK   Level = "OK"
	WARN Level = "WARN"
	FAIL Level = "FAIL"
)

type Options

type Options struct {
	Settings config.Settings // kubetective.yaml contents
	// SettingsErr is the yaml parse error (nil when absent or clean).
	SettingsErr error
	// SettingsMissing marks a missing file: WARN (optional file), not FAIL.
	SettingsMissing bool
	// StateDir is the KubeTective home (default via config.DefaultDir).
	StateDir string
	// ConfigPath is config.json for calibration state.
	ConfigPath string
	// PrometheusURL/LokiURL from settings/env ("" = not configured -> OK).
	PrometheusURL string
	LokiURL       string
	// HubCheck verifies kubeconfig/cluster; when nil the kubeconfig check
	// only verifies the file exists.
	HubCheck func(ctx context.Context) error
}

Options control which checks run. Zero-ish values degrade gracefully.

type Report

type Report struct {
	EngineVersion string  `json:"engine_version"`
	Checks        []Check `json:"checks"`
}

Report is the full doctor output.

func Run

func Run(ctx context.Context, o Options) Report

Run executes the check set and returns the report; exit code is the caller's (report.Failing()).

func (*Report) Failing

func (r *Report) Failing() bool

Failing reports whether any check reached FAIL.

Jump to

Keyboard shortcuts

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