report

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package report defines the structure and rendering of RestoreLab recovery drill reports.

A Report is populated by the workflow orchestrator and can be serialized to JSON or HTML. It intentionally avoids scores like "85/100" — only categorical outcomes (PASS/FAIL/WARNING/...) which are honest about what was and was not tested.

Index

Constants

View Source
const CurrentVersion = "1.0"

CurrentVersion is the report schema version.

Variables

This section is empty.

Functions

func DefaultScopeNotes

func DefaultScopeNotes() []string

DefaultScopeNotes returns the standard scope limitations for the v0.1.0 release. These strings are deliberately factual and contain no unverified statistics.

Types

type Check

type Check struct {
	Name     string `json:"name"`
	Status   Status `json:"status"`
	Expected string `json:"expected,omitempty"`
	Actual   string `json:"actual,omitempty"`
	Error    string `json:"error,omitempty"`
}

Check is one SQL validation result.

type Report

type Report struct {
	// Identity
	Version      string    `json:"version"`
	RunID        string    `json:"run_id"`
	ContractName string    `json:"contract_name"`
	ContractPath string    `json:"contract_path"`
	StartedAt    time.Time `json:"started_at"`
	CompletedAt  time.Time `json:"completed_at"`
	DurationMS   int64     `json:"duration_ms"`

	// Environment facts
	ResticVersion   string `json:"restic_version,omitempty"`
	PostgresVersion string `json:"postgres_version,omitempty"`
	ImageDigest     string `json:"image_digest,omitempty"`
	ArtifactSize    int64  `json:"artifact_size,omitempty"`

	// Results
	Stages        []Stage `json:"stages"`
	Checks        []Check `json:"checks,omitempty"`
	Overall       Status  `json:"overall"`
	FailureReason string  `json:"failure_reason,omitempty"`
	CleanupStatus Status  `json:"cleanup_status"`

	// Scope: explicitly records what was and was not tested.
	ScopeNotes []string `json:"scope_notes,omitempty"`
}

Report is the complete outcome of a single recovery drill.

func New

func New(runID, contractName, contractPath string) *Report

New creates a Report with identity fields set and status values initialized to NOT_RUN.

func (*Report) AddCheck

func (r *Report) AddCheck(c Check)

AddCheck appends a check result to the report.

func (*Report) AddStage

func (r *Report) AddStage(s Stage)

AddStage appends a completed stage to the report.

func (*Report) FillNotRun

func (r *Report) FillNotRun(canonical []string)

FillNotRun marks every stage in canonical that does not already appear in r.Stages as StatusNotRun, preserving the canonical order at the end of the stage list. This is called by the workflow before Finalize so that early-return paths still produce a report that shows every stage.

func (*Report) Finalize

func (r *Report) Finalize()

Finalize sets CompletedAt, DurationMS, and computes Overall. It must be called exactly once before serializing the report.

func (*Report) WriteHTML

func (r *Report) WriteHTML(w io.Writer) error

WriteHTML renders the report as HTML to w.

func (*Report) WriteHTMLFile

func (r *Report) WriteHTMLFile(path string) error

WriteHTMLFile renders the report to the given file path. The file is written with mode 0600.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

WriteJSON serializes the report as indented JSON to w.

func (*Report) WriteJSONFile

func (r *Report) WriteJSONFile(path string) error

WriteJSONFile writes the report to the given file path, creating or truncating the file. The file is written with mode 0600.

type Stage

type Stage struct {
	Name       string `json:"name"`
	Status     Status `json:"status"`
	Message    string `json:"message,omitempty"`
	Error      string `json:"error,omitempty"`
	DurationMS int64  `json:"duration_ms"`
}

Stage is one step of the recovery drill.

type Status

type Status string

Status is the categorical outcome of a stage or check.

const (
	StatusPass    Status = "PASS"
	StatusFail    Status = "FAIL"
	StatusWarning Status = "WARNING"
	StatusNotRun  Status = "NOT_RUN"
	StatusSkipped Status = "SKIPPED"
)

Jump to

Keyboard shortcuts

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