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

run

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package run is the orchestration layer behind `driftsync check` and `driftsync sync`: it reads a validated config, extracts the code-side spec, canonicalizes both sides, diffs them, and (for sync) proposes, enriches, and applies the fix. 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 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.
	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
	// 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