doctor

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package doctor runs end-to-end preflight diagnostics for a notifycat installation. It bundles config, database, and mappings-file checks the server would otherwise only surface at startup, and (for a target repository) delegates the per-mapping Slack + GitHub checks to internal/validate. The CLI entry point lives in cmd/notifycat-doctor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteReport

func WriteReport(w io.Writer, sections []Section) bool

WriteReport renders sections to w in a human-readable, greppable form, and returns true iff no check failed (skipped checks do not fail the report). The format is intentionally plain text: one section header per group, then one indented line per check.

Types

type Doctor

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

Doctor bundles a parsed config with an optional RepoValidator. Construct once via NewDoctor; Run is safe to call multiple times.

func NewDoctor

func NewDoctor(cfg config.Config, validator RepoValidator) *Doctor

NewDoctor returns a Doctor wired to cfg and validator. validator may be nil — Run then skips the per-repo Slack/GitHub checks even when a target repository is given.

func (*Doctor) Run

func (d *Doctor) Run(ctx context.Context, target string) []Section

Run produces the report. The first three sections (config, database, mappings) always run, in that order. When target is non-empty and a validator is configured, a fourth section named after target is appended with the per-mapping check results.

type RepoValidator

type RepoValidator interface {
	Validate(ctx context.Context, repository string) validate.Report
}

RepoValidator is the slice of validate.Validator the doctor needs. It stays in this consumer package so tests can supply a hand-written fake without depending on the live Slack / GitHub clients.

type Section

type Section struct {
	Name   string
	Checks []validate.CheckResult
}

Section is a named group of related checks (e.g. "config", "database", "octo/widget"). Each section's checks are independent — a single FAIL in one section does not short-circuit other sections.

func CheckConfig

func CheckConfig(cfg config.Config) Section

CheckConfig inspects cfg and reports per-field results. Secret values are never written to Detail — the result reports only "set" or "missing".

func CheckDatabase

func CheckDatabase(dsn string) Section

CheckDatabase opens dsn, pings the underlying connection, and reports the result. It does not run migrations — that is the server's job.

func CheckMappingsFile

func CheckMappingsFile(path string) Section

CheckMappingsFile loads the mappings file via internal/mappings.Load and reports whether the file exists and parses cleanly. An empty mappings map is OK (the server treats it as a no-op).

func (Section) OK

func (s Section) OK() bool

OK reports whether every check in the section passed (StatusSkip does not count as a failure).

Jump to

Keyboard shortcuts

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