Documentation
¶
Index ¶
- Constants
- func Format(w io.Writer, u Unified)
- func FormatString(u Unified) string
- func FormatSummary(w io.Writer, result *DiffResult)
- func FormatUnifiedDiff(w io.Writer, result *DiffResult)
- func ReorderFilter() func([]*yaml.RNode) ([]*yaml.RNode, error)
- type DiffChangeJSON
- type DiffResult
- type DiffResultJSON
- type Hunk
- type Line
- type ObjectRef
- type OpKind
- type ResourceChange
- type Unified
Constants ¶
const ( Delete = gotextdiff.Delete Insert = gotextdiff.Insert Equal = gotextdiff.Equal )
Variables ¶
This section is empty.
Functions ¶
func FormatString ¶
FormatString renders a unified diff as a string.
func FormatSummary ¶
func FormatSummary(w io.Writer, result *DiffResult)
FormatSummary writes a compact list of changed resources.
func FormatUnifiedDiff ¶
func FormatUnifiedDiff(w io.Writer, result *DiffResult)
FormatUnifiedDiff writes a plain-text summary of the diff.
func ReorderFilter ¶
ReorderFilter returns a kio.Filter that reorders fields in each manifest to follow Kubernetes conventions: apiVersion, kind, metadata, spec, status, ... Unknown fields are preserved at the end in their original order.
Types ¶
type DiffChangeJSON ¶
type DiffChangeJSON struct {
ObjectRef ObjectRef `json:"objectRef"`
Old map[string]any `json:"old"`
New map[string]any `json:"new"`
UnifiedDiff string `json:"unifiedDiff"`
}
DiffChangeJSON represents a modified resource with before/after snapshots.
type DiffResult ¶
type DiffResult struct {
Added []ObjectRef
Removed []ObjectRef
Modified []ResourceChange
}
DiffResult holds the structured result of a diff between two manifest sets.
func DiffNodes ¶
func DiffNodes(before, after []*yaml.RNode) (*DiffResult, error)
DiffNodes computes a semantic diff between two sets of Kubernetes manifests. Resources are matched by identity (apiVersion + kind + namespace + name).
func (*DiffResult) HasChanges ¶
func (r *DiffResult) HasChanges() bool
HasChanges reports whether any resources were added, removed, or modified.
type DiffResultJSON ¶
type DiffResultJSON struct {
Added []map[string]any `json:"added"`
Deleted []ObjectRef `json:"deleted"`
Modified []DiffChangeJSON `json:"modified"`
}
DiffResultJSON is the JSON representation of a manifest diff.
func DiffNodesJSON ¶
func DiffNodesJSON(before, after []*yaml.RNode) (*DiffResultJSON, error)
DiffNodesJSON computes a diff and returns a JSON-serializable result.
type Hunk ¶
type Hunk = gotextdiff.Hunk
Re-export gotextdiff types so consumers don't need to import it directly.
type Line ¶
type Line = gotextdiff.Line
Re-export gotextdiff types so consumers don't need to import it directly.
type ObjectRef ¶
type ObjectRef struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
}
ObjectRef mirrors the Kubernetes ObjectReference shape used in Events, OwnerReferences, and other cross-resource references.
func ObjectRefFromMeta ¶
func ObjectRefFromMeta(meta yaml.ResourceMeta) ObjectRef
ObjectRefFromMeta builds an ObjectRef from kyaml ResourceMeta.
type OpKind ¶
type OpKind = gotextdiff.OpKind
Re-export gotextdiff types so consumers don't need to import it directly.
type ResourceChange ¶
ResourceChange describes a single modified resource.
type Unified ¶
type Unified = gotextdiff.Unified
Re-export gotextdiff types so consumers don't need to import it directly.
func ComputeDiff ¶
ComputeDiff computes a Myers diff between two multi-line strings and returns a Unified diff structure.