doctor

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 9 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.

Orchestration lives here; each section's checks live in their own *_check.go file (config_check.go, database_check.go, mappings_check.go), and the okResult/failResult/skip constructors live in helpers.go — the same layout the sibling internal/validate package uses.

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 CheckMappings added in v0.17.0

func CheckMappings(provider *mappings.Provider, hasGitHubToken bool) Section

CheckMappings reports whether the `mappings:` section of config.yaml parsed into any entries. An empty section is OK (the server boots but routes nothing). Parse failures already surface in config load, so by the time the doctor has a provider the file is structurally valid.

When any tier configures per-path routing, it adds a "path routing" check: OK when a GitHub token is present (paths are active), SKIP when it is absent (path rules are inert — PRs route to the repo tier — until a token is set).

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