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

run

package
v0.4.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: 15 Imported by: 0

Documentation

Overview

Package run is the orchestration layer behind `driftsync check`, `driftsync sync`, and `driftsync doctor`: it reads a validated config, extracts the code-side spec, canonicalizes both sides, diffs them, and (for sync) proposes, enriches, and applies the fix. Doctor runs the same extract-and-parse steps as a setup check, without diffing. The low-level packages (diff, patch, applier, enrich) stay unaware of the config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoctorResult added in v0.4.0

type DoctorResult struct {
	Steps []DoctorStep
	OK    bool
}

DoctorResult is the outcome of a Doctor run: an ordered checklist, stopping at the first failure since every later stage depends on the one before it.

func Doctor added in v0.4.0

func Doctor(ctx context.Context, o Options) *DoctorResult

Doctor validates a driftsync SETUP end to end — that code.command runs and produces a file, and that both the code and published specs actually parse as OpenAPI — without diffing them against each other. It's for onboarding ("is my driftsync.yaml wired up right"), not for finding drift; use Check for that. o.Config is assumed already loaded (config.Load succeeded) — that's the caller's own checklist line, not this function's.

type DoctorStep added in v0.4.0

type DoctorStep struct {
	Name string
	OK   bool
	// Detail is a human-readable outcome on success, or the error on failure.
	Detail string
}

DoctorStep is one checklist item from Doctor.

type Options

type Options struct {
	Config *config.Config
	// Enricher fills descriptions for brand-new fields in sync mode. Nil skips
	// the step entirely (descriptions stay blank). Ignored by Check and Doctor.
	Enricher enrich.Enricher
	// Stderr receives the extraction command's stdout+stderr chatter, so the
	// rendered report on the real stdout stays clean. Defaults to os.Stderr.
	Stderr io.Writer
}

Options drives a run. The CLI fills it in; tests construct it directly.

type Result

type Result struct {
	Report         *diff.Report
	RenderedReport string // per Config.Report (text | md | json)
	Patches        []patch.Patch
	Applied        int
	Failed         []applier.Failure
	Corrected      []byte // sync only: the rewritten published spec
	// RenameHints are LLM-suggested (advisory only) semantic renames the
	// deterministic matcher didn't catch. Sync only, and only when Enricher is
	// set. Already folded into RenderedReport for text/md; kept here too for
	// programmatic access. See enrich.SuggestRenames.
	RenameHints []enrich.RenameHint
	// ExitCode is the process exit code check should use, per Config.FailOn.
	// Always 0 for Sync (the PR is the gate).
	ExitCode int
}

Result is what a run produced.

func Check

func Check(ctx context.Context, o Options) (*Result, error)

Check extracts the code spec, diffs it against the published spec, and renders a report. It never writes anything.

func Sync

func Sync(ctx context.Context, o Options) (*Result, error)

Sync does everything Check does, then proposes patches, optionally enriches them, applies them to the published bytes, and returns the corrected spec in Result.Corrected. It still does not write to disk — the caller does.

Jump to

Keyboard shortcuts

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