diffprep

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package diffprep owns canonical diff preparation independently of output formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareSnapshots

func PrepareSnapshots(orig, current Snapshot, opts *Options) (Prepared, []Suppression)

PrepareSnapshots pairs the documents Suppress retains under each side's comparison identities.

Types

type Doc

type Doc struct {
	Manifest map[string]any
	Parent   Parent
}

Doc borrows an immutable document and its producer attribution.

func Documents

func Documents(manifests []manifest.DocumentBatch) []Doc

Documents projects selected batches without copying their immutable manifests.

type Options

type Options struct {
	Subjects    [2]map[manifest.NamedResource]manifest.DiagnosticIdentity
	StripAttrs  []string
	StripFields []string
	Normalize   func(map[string]any)
	// contains filtered or unexported fields
}

Options controls normalization before canonical pairing.

type Pair

type Pair struct {
	Parent             Parent
	Resource           manifest.NamedResource
	APIVersion         string
	OldPos, NewPos     int
	Old, New           map[string]any
	OldChart, NewChart string
}

Pair retains normalized sides and authored attribution for a canonical resource pair.

func (*Pair) Status

func (p *Pair) Status() string

Status classifies the pair, returning an empty string for equal sides.

type Parent

type Parent struct {
	manifest.NamedResource

	Path string
}

Parent identifies a producer and its display path.

type Prepared

type Prepared struct {
	Subjects [2]map[manifest.NamedResource]manifest.DiagnosticIdentity
	Pairs    []Pair
	Warnings []manifest.Warning
	// contains filtered or unexported fields
}

Prepared retains unchanged pairs for native document-count and ordering semantics.

func Prepare

func Prepare(left, right []Doc, opts *Options) Prepared

Prepare normalizes and pairs documents, retaining the last normalized duplicate.

func (Prepared) Changes

func (p Prepared) Changes() iter.Seq2[Pair, string]

Changes yields changed pairs and statuses with manifests independent of the inputs.

func (Prepared) Native

func (p Prepared) Native() (dyff.Report, error)

Native prepares dyff inputs and compares each canonical pair exactly once.

type Side

type Side string

Side identifies an unavailable comparison side.

const (
	SideOrig    Side = "orig"
	SideCurrent Side = "current"
	SideBoth    Side = "both"
)

Comparison sides use the CLI orig/current vocabulary.

type Snapshot

type Snapshot struct {
	Subjects    map[manifest.NamedResource]manifest.DiagnosticIdentity
	Manifests   []manifest.DocumentBatch
	Unavailable map[manifest.NamedResource]store.StatusInfo
	// ProducerKeys maps actual producers to their paired comparison identities.
	ProducerKeys map[manifest.NamedResource]manifest.NamedResource
}

Snapshot contains immutable selected batches and producer availability.

type Suppression

type Suppression struct {
	Parent  Parent
	Subject manifest.DiagnosticIdentity
	Side    Side
	Count   int
	Reason  string
}

Suppression discloses withheld producer output.

func (Suppression) String

func (s Suppression) String() string

String renders the suppression as a human-readable sentence.

type SuppressionResult

type SuppressionResult struct {
	Orig, Current []manifest.DocumentBatch
	Suppressed    []Suppression
}

SuppressionResult keeps both retained sides with their shared withholding reasons.

func Suppress

func Suppress(orig, current Snapshot) SuppressionResult

Suppress withholds unavailable producer batches on both comparison sides. Producer identity excludes paths; counts measure withheld document entries.

Jump to

Keyboard shortcuts

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