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

doctor

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package doctor checks that the host, tools, cluster and services an Obol Stack needs are healthy, and says exactly how to fix what isn't. Checks are read-only; the few safe, idempotent repairs run only with --fix.

Index

Constants

View Source
const (
	GroupHost     = "Host"
	GroupTools    = "Tools"
	GroupStack    = "Stack"
	GroupServices = "Services"
	GroupTunnel   = "Tunnel"
	GroupWallets  = "Wallets"
)

Check groups, in display order.

View Source
const ClusterCheckID = "cluster"

ClusterCheckID runs first; checks with NeedsCluster wait on its result.

Variables

Groups in display order.

Functions

This section is empty.

Types

type Check

type Check struct {
	ID    string
	Group string
	Title string
	// NeedsCluster checks are skipped when the stack isn't reachable.
	NeedsCluster bool
	// Online checks reach the internet; --offline skips them.
	Online bool
	Run    func(ctx context.Context, e *Env) Result
	// Repair, when set, is a safe idempotent fix that --fix runs for results
	// the check marked Fixable.
	Repair func(ctx context.Context, e *Env) error
}

Check is one diagnostic.

func Checks

func Checks(r Repairs) []Check

Checks returns every check in display order. repairs supplies the fixes that need UI or side-effecting packages the doctor package doesn't import.

type Env

type Env struct {
	Cfg *config.Config
	// Run executes a host command and returns its stdout.
	Run func(ctx context.Context, name string, args ...string) ([]byte, error)
	// LookupHost resolves a hostname.
	LookupHost func(ctx context.Context, host string) ([]string, error)
	// Listen probes whether a local TCP address is free.
	Listen func(addr string) error
	// HTTP is used for local and public probes.
	HTTP *http.Client
	// FreeBytes reports free space on the filesystem holding path.
	FreeBytes func(path string) (uint64, error)
	// Offline: checks must not touch the internet (tunnel skips its probes).
	Offline bool
	// contains filtered or unexported fields
}

Env is everything a check touches, so tests can fake it.

func NewEnv

func NewEnv(cfg *config.Config) *Env

NewEnv returns the real environment.

func (*Env) ClusterUp

func (e *Env) ClusterUp() bool

ClusterUp reports whether the stack's API server answered.

func (*Env) Kubectl

func (e *Env) Kubectl(ctx context.Context, args ...string) ([]byte, error)

Kubectl runs obol's kubectl against the stack kubeconfig.

type Options

type Options struct {
	Offline bool
	Fix     bool
	Timeout time.Duration
}

Options control a run.

type Repairs

type Repairs struct {
	InstallTools      func(ctx context.Context, e *Env) error
	RefreshKubeconfig func(ctx context.Context, e *Env) error
	PopulateCABundle  func(ctx context.Context, e *Env) error
}

Repairs are the safe, idempotent fixes --fix may run. Nil entries mean the check reports a command instead.

type Result

type Result struct {
	ID      string `json:"id"`
	Group   string `json:"group"`
	Title   string `json:"title"`
	Status  Status `json:"status"`
	Message string `json:"message"`
	// Fix is the exact command (or step) that resolves a warn/fail.
	Fix string `json:"fix,omitempty"`
	// Fixable means `obol doctor --fix` can repair it; Fixed that it did.
	Fixable bool `json:"fixable,omitempty"`
	Fixed   bool `json:"fixed,omitempty"`
}

Result is what a check found.

func Run

func Run(ctx context.Context, e *Env, checks []Check, opts Options) []Result

Run executes every check: the cluster probe first (others depend on it), then the rest concurrently, each bounded by Options.Timeout. Results come back in display order.

type Status

type Status string

Status of one check, ordered by severity.

const (
	StatusOK   Status = "ok"
	StatusInfo Status = "info"
	StatusSkip Status = "skip"
	StatusWarn Status = "warn"
	StatusFail Status = "fail"
)

type Summary

type Summary struct {
	OK, Warn, Fail, Skip int
}

Summary counts results by severity.

func Summarize

func Summarize(results []Result) Summary

Summarize counts results; info counts as ok.

Jump to

Keyboard shortcuts

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