doctor

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package doctor provides environment diagnostics for roji.

It checks the system environment for common issues and can auto-fix some problems when requested.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasErrors

func HasErrors(results []CheckResult) bool

HasErrors returns true if any check failed

func HasWarnings

func HasWarnings(results []CheckResult) bool

HasWarnings returns true if any check has warnings

Types

type Check

type Check interface {
	// Name returns the name of this check
	Name() string

	// Run executes the check and returns the result
	Run(ctx context.Context, cfg *Config) CheckResult

	// CanFix returns whether this check supports auto-fixing
	CanFix() bool

	// Fix attempts to fix the issue found by this check
	// Should only be called if CanFix returns true and Run returned Fail/Warn
	Fix(ctx context.Context, cfg *Config) error
}

Check is the interface that all diagnostic checks must implement

type CheckResult

type CheckResult struct {
	Name    string `json:"name"`    // Name of the check
	Status  Status `json:"status"`  // Result status
	Message string `json:"message"` // Human-readable message
	Details string `json:"details"` // Additional details (optional)
	Fixable bool   `json:"fixable"` // Whether the issue can be auto-fixed
}

CheckResult represents the result of a single check

type Config

type Config struct {
	Settings   *config.Settings
	CertsDir   string
	ConfigPath string // Path to the config file (for validation)
}

Config holds configuration for running checks

type Doctor

type Doctor struct {
	// contains filtered or unexported fields
}

Doctor runs diagnostic checks on the system

func New

func New(cfg *Config) *Doctor

New creates a new Doctor with the given configuration

func (*Doctor) AddCheck

func (d *Doctor) AddCheck(check Check)

AddCheck adds a check to the doctor

func (*Doctor) Fix

func (d *Doctor) Fix(ctx context.Context) ([]CheckResult, error)

Fix attempts to fix all fixable issues

func (*Doctor) RunAll

func (d *Doctor) RunAll(ctx context.Context) []CheckResult

RunAll runs all registered checks and returns the results

type Status

type Status int

Status represents the result status of a check

const (
	// Pass indicates the check passed successfully
	Pass Status = iota
	// Warn indicates a non-critical issue was found
	Warn
	// Fail indicates a critical issue was found
	Fail
)

func (Status) String

func (s Status) String() string

String returns a human-readable status string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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