reconcile

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conflict

type Conflict struct {
	Unit      string
	Section   string
	Key       string
	User      string
	Generated string
}

Conflict describes a directive changed by both the user (via `comquad edit`) and by compose.yaml regeneration. The user's value wins; the conflict is reported so nothing is silently dropped.

func MergeUnit

func MergeUnit(base, disk, new c2q.QuadletUnit) (c2q.QuadletUnit, []Conflict)

MergeUnit performs a directive-level three-way merge of a generated quadlet unit and its on-disk counterpart, using the previously generated content as the common base. On conflict the user's (disk) value wins and the conflict is returned. The merged unit always adopts the type and name of new.

type FilePlan

type FilePlan struct {
	Name            string
	TargetPath      string
	BasePath        string
	Status          FileStatus
	OldContent      string
	NewContent      string
	BaselineContent string
	NoBaseline      bool
	Conflicts       []Conflict
}

FilePlan describes what will happen to a single quadlet file.

func (FilePlan) Diff

func (fp FilePlan) Diff() string

Diff renders the unified diff for a single file (empty if unchanged).

type FileStatus

type FileStatus int

FileStatus classifies how a generated unit relates to what is on disk.

const (
	StatusUnchanged FileStatus = iota
	StatusCreated
	StatusChanged
	StatusRemoved
)

type Plan

type Plan struct {
	Files      []FilePlan
	Conflicts  []Conflict
	NoBaseline []string
}

Plan is a read-only preview of a reconcile pass.

func Compute

func Compute(targetDir, baselineDir, prefix string, units []c2q.QuadletUnit) (Plan, error)

Compute builds a Plan describing the changes needed without touching disk.

func (Plan) Diff

func (p Plan) Diff() string

Diff renders a unified diff of the plan for user display. It covers created, changed, and removed files; unchanged files produce no output.

func (Plan) HasChanges

func (p Plan) HasChanges() bool

HasChanges reports whether applying the plan would modify anything.

type Result

type Result struct {
	Created    []string // files that did not exist and were written
	Changed    []string // existing files whose content changed and were rewritten
	Removed    []string // stale target files removed (no longer generated)
	NoBaseline []string // files overwritten without a baseline (2-way fallback)
	Conflicts  []Conflict
}

Result summarizes a Reconcile pass.

func Apply

func Apply(targetDir, baselineDir string, plan Plan) (Result, error)

Apply executes a Plan, writing files, updating baselines, and removing stale entries. It returns a Result summarizing what changed.

func Reconcile

func Reconcile(targetDir, baselineDir, prefix string, units []c2q.QuadletUnit) (Result, error)

Reconcile computes and applies changes in a single step.

Jump to

Keyboard shortcuts

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