watchdiff

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Differ

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

Differ maintains per-session state for computing diffs between successive versions of Kubernetes objects.

It caches the last-seen version of each object and uses Printer to render git-style diffs between the cached and new versions.

func NewDiffer

func NewDiffer(showTimestamp bool) *Differ

NewDiffer creates a new Differ.

func (*Differ) Diff

func (d *Differ) Diff(obj *unstructured.Unstructured) (string, error)

Diff computes the diff between the last cached version of obj and the current version. The cache is updated to the new version.

It returns an empty string if there is no effective change.

func (*Differ) DiffDelete

func (d *Differ) DiffDelete(obj *unstructured.Unstructured) (string, error)

DiffDelete computes a diff that represents deletion of the object previously seen with the same identity. If the object was not seen before, it returns an empty string.

func (*Differ) SetIgnoreMeta

func (d *Differ) SetIgnoreMeta(ignore bool)

SetIgnoreMeta controls whether non-essential metadata is excluded from diffs.

func (*Differ) SetIgnoreStatus

func (d *Differ) SetIgnoreStatus(ignore bool)

SetIgnoreStatus controls whether the status field is excluded from diffs.

type Printer

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

Printer formats diffs between two unstructured Kubernetes objects. It is inspired by kubectl-yadt's DiffPrinter but outputs plain text without terminal color codes so it is suitable for MCP tool responses.

func NewPrinter

func NewPrinter(showTimestamp bool) *Printer

NewPrinter creates a new Printer.

func (*Printer) Diff

func (p *Printer) Diff(oldObj, newObj *unstructured.Unstructured) (string, error)

Diff computes a git-style diff between two objects and returns it as a string. The original objects should already have had any ignoreStatus/ignoreMeta transformations applied.

Jump to

Keyboard shortcuts

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