Documentation
¶
Overview ¶
Package diff provides functionality for comparing Kubernetes objects and generating diffs.
Index ¶
- func AssertResourceChange(t *testing.T, results Results, expectedKey string, ...)
- type ChangeType
- type Options
- type ResourceKey
- type Result
- type Results
- func (dr Results) Apply(filter func(ResourceKey, Result) bool) Results
- func (dr Results) Count() int
- func (dr Results) CountByType(changeType ChangeType) int
- func (dr Results) FilterByKind(kind string) Results
- func (dr Results) FilterByNamespace(namespace string) Results
- func (dr Results) FilterByResourceName(name string) Results
- func (dr Results) FilterByType(changeType ChangeType) Results
- func (dr Results) FilterChanged() Results
- func (dr Results) FilterCreated() Results
- func (dr Results) FilterDeleted() Results
- func (dr Results) FilterUnchanged() Results
- func (dr Results) GetResourceKeys() []ResourceKey
- func (dr Results) GetResourceKeysByType(changeType ChangeType) []ResourceKey
- func (dr Results) GetStatistics() Statistics
- func (dr Results) HasChanges() bool
- func (dr Results) IsEmpty() bool
- func (dr Results) StringDiff() string
- func (dr Results) StringDiffMarkdown() string
- func (dr Results) StringSummary() string
- func (dr Results) StringSummaryAsComments() string
- func (dr Results) StringSummaryMarkdown() string
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertResourceChange ¶
func AssertResourceChange(t *testing.T, results Results, expectedKey string, expectedChangeType ChangeType)
AssertResourceChange checks if a specific resource has the expected change type
Types ¶
type ChangeType ¶
type ChangeType int
ChangeType represents the type of change for a resource
const ( // Unchanged indicates that a resource exists in both base and head with no changes Unchanged ChangeType = iota // Changed indicates that a resource exists in both base and head with changes Changed // Created indicates that a resource exists only in head (newly created) Created // Deleted indicates that a resource exists only in base (deleted) Deleted )
func (ChangeType) String ¶
func (ct ChangeType) String() string
String returns the string representation of ChangeType
type Options ¶
type Options struct { FilterOption *filter.Option // Filtering options Context int // Number of context lines in diff output DisableMaskingSecrets bool // Disable masking of secret values (default: false) }
Options controls the diff behavior with filtering and masking options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns the default diff options
type ResourceKey ¶
ResourceKey uniquely identifies a Kubernetes resource
func GetChangedResourceKeys ¶
func GetChangedResourceKeys(results Results) []ResourceKey
GetChangedResourceKeys extracts resources that have any type of change (Created, Changed, Deleted) DEPRECATED: Use Results.Apply() with custom filter or multiple GetResourceKeysByType() calls
func ParseResourceKey ¶
func ParseResourceKey(key string) ResourceKey
ParseResourceKey parses a string resource key into ResourceKey
func (ResourceKey) String ¶
func (k ResourceKey) String() string
String returns a string representation of the ResourceKey
type Result ¶
type Result struct { Type ChangeType // Type of change (Created, Changed, Deleted, Unchanged) Diff string // Diff string representation }
Result represents the result of a diff operation for a resource
type Results ¶
type Results map[ResourceKey]Result
Results represents a collection of diff results for multiple resources
func Objects ¶
func Objects(base, head []*unstructured.Unstructured, opts *Options) (Results, error)
Objects compares two sets of Kubernetes objects and returns the diff
func YamlString ¶
YamlString compares two YAML strings and returns the diff
func (Results) Apply ¶
func (dr Results) Apply(filter func(ResourceKey, Result) bool) Results
Apply returns a new Results containing only resources that match the filter function
func (Results) CountByType ¶
func (dr Results) CountByType(changeType ChangeType) int
CountByType returns the number of resources with the specified change type
func (Results) FilterByKind ¶
FilterByKind returns a new Results containing only resources with the specified kind
func (Results) FilterByNamespace ¶
FilterByNamespace returns a new Results containing only resources with the specified namespace
func (Results) FilterByResourceName ¶
FilterByResourceName returns a new Results containing only resources with the specified name
func (Results) FilterByType ¶
func (dr Results) FilterByType(changeType ChangeType) Results
FilterByType returns a new Results containing only resources with the specified change type
func (Results) FilterChanged ¶
FilterChanged returns a new Results containing only changed resources
func (Results) FilterCreated ¶
FilterCreated returns a new Results containing only created resources
func (Results) FilterDeleted ¶
FilterDeleted returns a new Results containing only deleted resources
func (Results) FilterUnchanged ¶
FilterUnchanged returns a new Results containing only unchanged resources
func (Results) GetResourceKeys ¶
func (dr Results) GetResourceKeys() []ResourceKey
GetResourceKeys returns a slice of all resource keys in the Results
func (Results) GetResourceKeysByType ¶
func (dr Results) GetResourceKeysByType(changeType ChangeType) []ResourceKey
GetResourceKeysByType returns a slice of resource keys with the specified change type
func (Results) GetStatistics ¶
func (dr Results) GetStatistics() Statistics
GetStatistics returns statistics about the diff results
func (Results) HasChanges ¶
HasChanges returns true if there are any changes (Created, Changed, or Deleted resources)
func (Results) StringDiff ¶
StringDiff returns a concatenated string of all diff results with summary header
func (Results) StringDiffMarkdown ¶ added in v0.0.5
StringDiffMarkdown returns a concatenated string of all diff results with markdown formatting
func (Results) StringSummary ¶
StringSummary returns a summary string organized by change types: Unchanged, Changed, Create, Delete
func (Results) StringSummaryAsComments ¶
StringSummaryAsComments returns the summary content formatted as comment lines
func (Results) StringSummaryMarkdown ¶ added in v0.0.5
StringSummaryMarkdown returns a summary string in Markdown format