diff

package
v0.19.1236 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	Key           string         `json:"key"`
	ResourceID    NodeID         `json:"resource_id,omitempty"`
	Diff          *DiffKey       `json:"diff,omitempty"`
	Children      []*Diff        `json:"children,omitempty"`
	Impacted      bool           `json:"impacted,omitempty"`
	ImpactReasons []ImpactReason `json:"impact_reasons,omitempty"`
}

func MapDiff added in v0.19.1012

func MapDiff(key string, old, new map[string]string) *Diff

MapDiff diffs two map[string]string values, returning a parent node with per-key children. Returns nil if both maps are empty/nil.

func NewDiff

func NewDiff(opts ...DiffOption) *Diff

func (*Diff) ApplyImpacts added in v0.19.1188

func (d *Diff) ApplyImpacts(impacts map[NodeID][]ImpactReason)

ApplyImpacts annotates resource nodes in the tree with propagated graph impacts. It leaves their direct Diff operations unchanged.

func (*Diff) DirectSummary added in v0.19.1188

func (d *Diff) DirectSummary() DiffSummary

DirectSummary ignores dependency impacts and reports only value changes.

func (*Diff) FindResource added in v0.19.1188

func (d *Diff) FindResource(id NodeID) *Diff

func (*Diff) FormatChanged added in v0.19.1012

func (d *Diff) FormatChanged(indent string) string

FormatChanged returns only the parts of the diff tree that have changes (added, removed, or changed). Unchanged fields and sections are omitted entirely.

func (*Diff) String

func (d *Diff) String(indent string) string

String returns the full diff tree with +/-/~ prefixes indicating added, removed, changed, and unchanged fields. Empty unchanged fields (both old and new are "") are suppressed.

func (*Diff) Summary

func (d *Diff) Summary() DiffSummary

type DiffKey

type DiffKey struct {
	Op     Op     `json:"op"`
	Diff   string `json:"diff"`
	Before string `json:"before,omitempty"`
	After  string `json:"after,omitempty"`
}

type DiffOption

type DiffOption func(*Diff)

func WithBoolDiff added in v0.19.1012

func WithBoolDiff(old, new bool) DiffOption

WithBoolDiff creates a DiffOption that compares two bool values.

func WithChildren

func WithChildren(children ...*Diff) DiffOption

func WithContentDiff added in v0.19.1024

func WithContentDiff(old, new string) DiffOption

WithContentDiff creates a DiffOption for file-like content. It derives the op from presence (add when old is empty, remove when new is empty, change otherwise), stores a short label in Diff for text renderers, and carries the raw before/after contents so consumers can render a line-by-line diff.

func WithKey

func WithKey(key string) DiffOption

func WithOptionalBoolDiff added in v0.19.1012

func WithOptionalBoolDiff(old, new *bool) DiffOption

WithOptionalBoolDiff creates a DiffOption that compares two *bool values, treating nil as false.

func WithOptionalStringDiff added in v0.19.1012

func WithOptionalStringDiff(old, new *string) DiffOption

WithOptionalStringDiff creates a DiffOption that compares two *string values, treating nil as empty string.

func WithResourceID added in v0.19.1188

func WithResourceID(id NodeID) DiffOption

func WithStringDiff

func WithStringDiff(old, new string) DiffOption

func WithStringSliceDiff added in v0.19.1012

func WithStringSliceDiff(old, new []string) DiffOption

WithStringSliceDiff creates a DiffOption that compares two string slices by sorting and joining them.

type DiffSummary

type DiffSummary struct {
	HasChanged bool `json:"has_changed"`
	Added      int  `json:"added"`
	Removed    int  `json:"removed"`
	Changed    int  `json:"changed"`
	Unchanged  int  `json:"unchanged"`
}

type Diffable

type Diffable interface {
	Diff() (string, Op)
}

type Edge added in v0.19.1188

type Edge struct {
	Dependent  NodeID     `json:"dependent"`
	Dependency NodeID     `json:"dependency"`
	Reason     EdgeReason `json:"reason"`
}

type EdgeReason added in v0.19.1188

type EdgeReason string
const (
	EdgeReasonComponentDependency EdgeReason = "component_dependency"
	EdgeReasonComponentReference  EdgeReason = "component_reference"
	EdgeReasonInputReference      EdgeReason = "input_reference"
	EdgeReasonInstallStackOutput  EdgeReason = "install_stack_output"
	EdgeReasonOperationRole       EdgeReason = "operation_role"
	EdgeReasonSandboxOutput       EdgeReason = "sandbox_output"
	EdgeReasonSecretReference     EdgeReason = "secret_reference"
	EdgeReasonStackRender         EdgeReason = "stack_render"
)

type Graph added in v0.19.1188

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph added in v0.19.1188

func NewGraph() *Graph

func (*Graph) AddDependency added in v0.19.1188

func (g *Graph) AddDependency(dependent, dependency NodeID, reason EdgeReason)

AddDependency records that dependent consumes dependency. Changes propagate in the reverse direction, from dependency to dependent.

func (*Graph) Propagate added in v0.19.1188

func (g *Graph) Propagate(changed ...NodeID) map[NodeID][]ImpactReason

Propagate returns every transitively impacted node and the immediate graph edge that caused each impact. Directly changed roots are not marked impacted.

type ImpactReason added in v0.19.1188

type ImpactReason struct {
	From NodeID     `json:"from"`
	Edge EdgeReason `json:"edge"`
}

type NodeID added in v0.19.1188

type NodeID string

type Op

type Op string
const (
	OpAdd     Op = "add"
	OpRemove  Op = "remove"
	OpChange  Op = "change"
	OpNoop    Op = "noop"
	OpUnknown Op = ""
)

type StringDiffer

type StringDiffer struct {
	// contains filtered or unexported fields
}

func (*StringDiffer) Diff

func (d *StringDiffer) Diff() (string, Op)

Jump to

Keyboard shortcuts

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