Help us shape the future of Go! Take the 2026 Go Developer Survey

diff

package
v0.19.1254 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRawResourceName

func ParseRawResourceName(s string) (namespace, name, kind, apiPath string)

ParseRawResourceName parses a resource name string in the format "namespace, name, kind (apiBase)"

Types

type DiffEntry

type DiffEntry struct {
	Path     string                 `json:"path,omitempty"`
	Original interface{}            `json:"original,omitempty"`
	Applied  interface{}            `json:"applied,omitempty"`
	Type     DiffEntryType          `json:"type"`
	Changes  map[string]interface{} `json:"changes,omitempty"` // For nested changes
	Payload  string                 `json:"payload,omitempty"` // For raw diff content or line content
}

DiffEntry represents a single change in a resource

func DetectChanges

func DetectChanges(original, applied map[string]interface{}, ignoreFields []string) ([]DiffEntry, bool)

DetectChanges compares original and applied objects and returns structured diff entries

type DiffEntryType

type DiffEntryType int

DiffEntryType represents the type of difference in a resource or property

const (
	// EntryUnchanged indicates no change
	EntryUnchanged DiffEntryType = iota
	// EntryRemoved indicates the resource or property was removed
	EntryRemoved
	// EntryAdded indicates the resource or property was added
	EntryAdded
	// EntryModified indicates the resource or property was modified
	EntryModified
	// EntryError indicates an error occurred during the diff
	EntryError
)

func (DiffEntryType) String

func (t DiffEntryType) String() string

String returns a human-readable string representation for DiffEntryType

func (DiffEntryType) Symbol

func (t DiffEntryType) Symbol() string

Symbol returns a single character representation for DiffEntryType (for visual diff)

type PlanContents

type PlanContents struct {
	Plan        string         `json:"plan"`
	Op          string         `json:"op"`
	ContentDiff []ResourceDiff `json:"content_diff"`
}

PlanContents is a common structure for both Helm and Kubernetes manifest plan contents

type ResourceDiff

type ResourceDiff struct {
	// Version identifier for this diff format
	Version string `json:"_version"`

	// Resource identification
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Kind      string `json:"kind,omitempty"`
	ApiPath   string `json:"api,omitempty"`
	Resource  string `json:"resource,omitempty"`

	// Operation details
	Operation string        `json:"op,omitempty"`
	Type      DiffEntryType `json:"type"`
	ErrorMsg  string        `json:"error,omitempty"`
	DryRun    bool          `json:"dry_run,omitempty"`

	// Detailed changes
	Entries []DiffEntry `json:"entries"`
}

ResourceDiff represents the diff for a Kubernetes resource Used by both Helm and Kubernetes manifest implementations

func FormatResourceDiffs

func FormatResourceDiffs(diffs []ResourceDiff) []ResourceDiff

FormatResourceDiffs converts all ResourceDiff objects in a slice to use line-by-line entries

func FormatToLineByLine

func FormatToLineByLine(resourceDiff ResourceDiff) ResourceDiff

FormatToLineByLine converts a ResourceDiff object to use line-by-line entries This provides a more readable diff for UI presentation

Jump to

Keyboard shortcuts

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