{"modulePath":"github.com/tobiash/gitops-preview-toolkit","version":"v0.2.0-rc.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package diff\n\n## Functions\n\n```go\nfunc BuildBreakdown(result *DiffResult, keyFn func(ResourceChange) string) map[string]ChangeBreakdown\n```\nBuildBreakdown groups changes by the given key function and returns breakdown counts.\n\n```go\nfunc ClusterBreakdown(result *DiffResult) map[string]ChangeBreakdown\n```\nClusterBreakdown returns change counts grouped by cluster name.\n\n```go\nfunc Diff(a, b *render.Render, w io.Writer) error\n```\nDiff computes a unified diff between two Renders and writes the result to w.\n\n```go\nfunc GenerateFilterConfig(diffs []FieldDiff) ([]byte, error)\n```\n\n```go\nfunc KindBreakdown(result *DiffResult) map[string]ChangeBreakdown\n```\nKindBreakdown returns change counts grouped by resource Kind.\n\n```go\nfunc UnifiedDiff(name, before, after string) string\n```\nUnifiedDiff computes a unified diff between before and after strings.\n\n```go\nfunc WritePermadiffConfig(a, b *render.Render, out io.Writer) error\n```\n\n## Types\n\n```go\ntype ChangeBreakdown struct {\n\tAdded    int `json:\"added\"`\n\tModified int `json:\"modified\"`\n\tDeleted  int `json:\"deleted\"`\n\tTotal    int `json:\"total\"`\n}\n```\nChangeBreakdown holds added/modified/deleted counts for a category like kind.\n\n```go\ntype DiffChangeJSON struct {\n\tLogicalID    string             `json:\"logicalId,omitempty\"`\n\tAction       string             `json:\"action\"`\n\tProvenance   render.Provenance  `json:\"provenance\"`\n\tBeforeOrigin *render.Provenance `json:\"beforeOrigin,omitempty\"`\n\tAfterOrigin  *render.Provenance `json:\"afterOrigin,omitempty\"`\n\tObjectRef    ObjectRef          `json:\"objectRef\"`\n\tCluster      string             `json:\"cluster,omitempty\"`\n\tProducer     string             `json:\"producer,omitempty\"`\n\tOld          map[string]any     `json:\"old\"`\n\tNew          map[string]any     `json:\"new\"`\n\tUnifiedDiff  string             `json:\"unifiedDiff\"`\n}\n```\nDiffChangeJSON represents a modified resource with before/after snapshots.\n\n```go\ntype DiffResult struct {\n\tClustered bool\n\tClusters  []string\n\tAdded     []ResourceChange\n\tDeleted   []ResourceChange\n\tModified  []ResourceChange\n}\n```\nDiffResult holds the structured result of a diff between two renders.\n\n```go\nfunc ChangeSet(a, b *render.Render) (*DiffResult, error)\n```\nChangeSet computes structured resource changes between two renders.\n\n```go\nfunc DiffWithResult(a, b *render.Render, w io.Writer) (*DiffResult, error)\n```\nDiffWithResult computes a unified diff and returns structured change metadata. The unified diff text is written to w.\n\n```go\nfunc DiffWithResultClustered(left, right map[string]*render.Render, w io.Writer) (*DiffResult, error)\n```\nDiffWithResultClustered diffs two sets of renders keyed by cluster name. Clusters present on both sides are diffed normally. Clusters only on the left side produce all-deleted results; clusters only on the right produce all-added results.\n\n```go\nfunc LogicalChangeSet(before, after []plugin.Resource) (*DiffResult, error)\n```\nLogicalChangeSet compares unnamed outputs by their stable logical IDs. Object comparison ignores YAML formatting, while diffs retain the original YAML.\n\n```go\nfunc (r *DiffResult) ByKind() map[string]int\n```\nByKind returns counts grouped by resource Kind.\n\n```go\nfunc (r *DiffResult) Changes() []ResourceChange\n```\nChanges returns all resource changes in added, modified, deleted order.\n\n```go\nfunc (r *DiffResult) Sort()\n```\nSort applies deterministic ordering to all change groups.\n\n```go\nfunc (r *DiffResult) Summary() ResultSummary\n```\nSummary returns common diff projections for reports and command output.\n\n```go\nfunc (r *DiffResult) ToJSON() *DiffResultJSON\n```\nToJSON converts the diff result to a JSON-serializable structure.\n\n```go\nfunc (r *DiffResult) TotalChanged() int\n```\nTotalChanged returns the total number of changed resources.\n\n```go\nfunc (r *DiffResult) WriteUnified(w io.Writer)\n```\nWriteUnified writes the unified text representation of a change set.\n\n```go\ntype DiffResultJSON struct {\n\tChanges  []DiffChangeJSON `json:\"changes\"`\n\tAdded    []map[string]any `json:\"added\"`\n\tDeleted  []ObjectRef      `json:\"deleted\"`\n\tModified []DiffChangeJSON `json:\"modified\"`\n}\n```\nDiffResultJSON is the JSON representation of a manifest diff.\n\n```go\ntype FieldDiff struct {\n\tLogicalID string\n\tGVK       resid.Gvk\n\tName      string\n\tNamespace string\n\tFieldPath []string\n\tIsLeaf    bool\n}\n```\n\n```go\nfunc DetectLogicalPermadiffs(before, after []plugin.Resource) ([]FieldDiff, error)\n```\nDetectLogicalPermadiffs discovers unstable fields in matched logical outputs.\n\n```go\nfunc DetectPermadiffs(a, b *render.Render) ([]FieldDiff, error)\n```\n\n```go\ntype NormalizationRule struct {\n\tMatch      filter.MatchCriteria\n\tFieldPaths []filter.FieldPath\n}\n```\n\n```go\nfunc GroupDiffsToRules(diffs []FieldDiff) []NormalizationRule\n```\n\n```go\ntype ObjectRef struct {\n\tAPIVersion string `json:\"apiVersion\"`\n\tKind       string `json:\"kind\"`\n\tName       string `json:\"name\"`\n\tNamespace  string `json:\"namespace,omitempty\"`\n}\n```\nObjectRef mirrors the Kubernetes ObjectReference shape.\n\n```go\ntype ResourceChange struct {\n\tLogicalID    string\n\tBeforeOrigin *render.Provenance\n\tAfterOrigin  *render.Provenance\n\tCluster      string\n\tID           resid.ResId\n\tKind         string\n\tName         string\n\tNamespace    string\n\tProvenance   render.Provenance\n\tProducer     string\n\tAction       string // added, deleted, modified\n\tOld          map[string]any\n\tNew          map[string]any\n\t// contains filtered or unexported fields\n}\n```\nResourceChange describes a single resource change in a diff.\n\n```go\nfunc (c ResourceChange) UnifiedDiff() string\n```\nUnifiedDiff returns the per-resource unified diff text for the change.\n\n```go\ntype ResultSummary struct {\n\tTotal            int\n\tClustered        bool\n\tClusters         []string\n\tByKind           map[string]int\n\tKindBreakdown    map[string]ChangeBreakdown\n\tClusterBreakdown map[string]ChangeBreakdown\n}\n```\nResultSummary contains precomputed projections of a rendered manifest diff.\n\n","path":"github.com/tobiash/gitops-preview-toolkit/pkg/diff","name":"diff","synopsis":"","isRedistributable":true}
