configdiff

package
v0.0.0-...-0b65b40 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigDiff

type ConfigDiff struct {
	StackName   string      `json:"stack_name"`
	ConfigType  string      `json:"config_type"`
	CompareFrom string      `json:"compare_from"`
	CompareTo   string      `json:"compare_to"`
	Changes     []DiffLine  `json:"changes"`
	Summary     DiffSummary `json:"summary"`
	Warnings    []string    `json:"warnings"`
	GeneratedAt time.Time   `json:"generated_at"`
}

ConfigDiff represents the differences between two configurations

type ConfigDiffParams

type ConfigDiffParams struct {
	StackName   string      `json:"stack_name"`
	ConfigType  string      `json:"config_type"`
	CompareWith string      `json:"compare_with"` // Git ref to compare with
	Options     DiffOptions `json:"options"`
}

ConfigDiffParams represents parameters for generating a config diff

type ConfigDiffResult

type ConfigDiffResult struct {
	Diff    *ConfigDiff `json:"diff"`
	Message string      `json:"message"` // Formatted output message
	Success bool        `json:"success"`
	Error   string      `json:"error,omitempty"`
}

ConfigDiffResult represents the result of a config diff operation

type ConfigDiffService

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

ConfigDiffService provides the main interface for configuration diffing

func NewConfigDiffService

func NewConfigDiffService(stacksMap api.StacksMap) *ConfigDiffService

NewConfigDiffService creates a new ConfigDiffService instance

func NewConfigDiffServiceWithProvider

func NewConfigDiffServiceWithProvider(stacksMap api.StacksMap, versionProvider ConfigVersionProvider) *ConfigDiffService

NewConfigDiffServiceWithProvider creates a new ConfigDiffService instance with a custom provider

func (*ConfigDiffService) GenerateConfigDiff

func (s *ConfigDiffService) GenerateConfigDiff(params ConfigDiffParams) (*ConfigDiffResult, error)

GenerateConfigDiff generates a configuration diff based on the provided parameters

func (*ConfigDiffService) GetConfigSnapshot

func (s *ConfigDiffService) GetConfigSnapshot(stackName, configType, ref string) (*ResolvedConfig, error)

GetConfigSnapshot gets a configuration snapshot for a specific reference

func (*ConfigDiffService) GetFormatDescription

func (s *ConfigDiffService) GetFormatDescription(format DiffFormat) string

GetFormatDescription returns a description of a specific format

func (*ConfigDiffService) GetSupportedFormats

func (s *ConfigDiffService) GetSupportedFormats() []DiffFormat

GetSupportedFormats returns the list of supported diff formats

func (*ConfigDiffService) ListAvailableStacks

func (s *ConfigDiffService) ListAvailableStacks() ([]string, error)

ListAvailableStacks returns a list of available stacks

func (*ConfigDiffService) ValidateStackExists

func (s *ConfigDiffService) ValidateStackExists(stackName string) error

ValidateStackExists checks if a stack exists in the current configuration

type ConfigResolver

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

ConfigResolver handles inheritance resolution

func NewConfigResolver

func NewConfigResolver(stacksMap api.StacksMap, versionProvider ConfigVersionProvider) *ConfigResolver

NewConfigResolver creates a new ConfigResolver instance

func (*ConfigResolver) ResolveStack

func (r *ConfigResolver) ResolveStack(stackName string, configType string) (*ResolvedConfig, error)

ResolveStack resolves a stack configuration with all inheritance applied

type ConfigVersionProvider

type ConfigVersionProvider interface {
	GetCurrent(stackName, configType string) (*ResolvedConfig, error)
	GetFromGit(stackName, configType, gitRef string) (*ResolvedConfig, error)
	GetFromLocal(stackName, configType, filePath string) (*ResolvedConfig, error)
}

ConfigVersionProvider interface for getting configuration versions

type ContextGroup

type ContextGroup struct {
	StartLine int
	OldLines  int
	NewLines  int
	Changes   []DiffLine
}

type DefaultConfigVersionProvider

type DefaultConfigVersionProvider struct{}

DefaultConfigVersionProvider implements ConfigVersionProvider

func NewDefaultConfigVersionProvider

func NewDefaultConfigVersionProvider() *DefaultConfigVersionProvider

NewDefaultConfigVersionProvider creates a new DefaultConfigVersionProvider

func (*DefaultConfigVersionProvider) GetCurrent

func (p *DefaultConfigVersionProvider) GetCurrent(stackName, configType string) (*ResolvedConfig, error)

GetCurrent gets the current configuration from the working directory

func (*DefaultConfigVersionProvider) GetFromGit

func (p *DefaultConfigVersionProvider) GetFromGit(stackName, configType, gitRef string) (*ResolvedConfig, error)

GetFromGit gets a configuration from a specific git reference

func (*DefaultConfigVersionProvider) GetFromLocal

func (p *DefaultConfigVersionProvider) GetFromLocal(stackName, configType, filePath string) (*ResolvedConfig, error)

GetFromLocal gets a configuration from a local file path

type DiffFormat

type DiffFormat string

DiffFormat represents the output format for configuration diffs

const (
	FormatUnified DiffFormat = "unified" // Git diff style with +/-
	FormatSplit   DiffFormat = "split"   // GitHub style, one line per change
	FormatInline  DiffFormat = "inline"  // Compact path: old → new
	FormatCompact DiffFormat = "compact" // Shortest, without stacks prefix
)

type DiffLine

type DiffLine struct {
	Type        DiffLineType `json:"type"`
	Path        string       `json:"path"` // YAML path (e.g., "stacks.prod.config.scale.min")
	OldValue    string       `json:"old_value"`
	NewValue    string       `json:"new_value"`
	LineNumber  int          `json:"line_number"`
	Context     []string     `json:"context"`     // Surrounding lines for context
	Description string       `json:"description"` // Human-readable description of change
	Warning     string       `json:"warning"`     // Optional warning about this change
}

DiffLine represents a single line change in the configuration

type DiffLineType

type DiffLineType string

DiffLineType represents the type of change

const (
	DiffLineAdded     DiffLineType = "added"
	DiffLineRemoved   DiffLineType = "removed"
	DiffLineModified  DiffLineType = "modified"
	DiffLineUnchanged DiffLineType = "unchanged"
)

type DiffOptions

type DiffOptions struct {
	Format           DiffFormat `json:"format"`
	ShowInheritance  bool       `json:"show_inheritance"`
	ContextLines     int        `json:"context_lines"`
	ObfuscateSecrets bool       `json:"obfuscate_secrets"`
	MaxChanges       int        `json:"max_changes"` // Limit output for large diffs
}

DiffOptions configures how the diff is generated and formatted

func DefaultDiffOptions

func DefaultDiffOptions() DiffOptions

DefaultDiffOptions returns sensible defaults for diff options

type DiffSummary

type DiffSummary struct {
	TotalChanges         int      `json:"total_changes"`
	Additions            int      `json:"additions"`
	Deletions            int      `json:"deletions"`
	Modifications        int      `json:"modifications"`
	EnvironmentsAffected []string `json:"environments_affected"`
	HasWarnings          bool     `json:"has_warnings"`
}

DiffSummary provides statistics about the changes

type Differ

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

Differ handles YAML configuration comparison

func NewDiffer

func NewDiffer(options DiffOptions) *Differ

NewDiffer creates a new Differ instance

func (*Differ) CompareConfigs

func (d *Differ) CompareConfigs(before, after *ResolvedConfig) (*ConfigDiff, error)

CompareConfigs compares two resolved configurations and returns the differences

type Formatter

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

Formatter handles different output formats for configuration diffs

func NewFormatter

func NewFormatter(options DiffOptions) *Formatter

NewFormatter creates a new Formatter instance

func (*Formatter) FormatDiff

func (f *Formatter) FormatDiff(diff *ConfigDiff) string

FormatDiff formats a ConfigDiff according to the specified format

type ResolvedConfig

type ResolvedConfig struct {
	StackName    string                 `json:"stack_name"`
	ConfigType   string                 `json:"config_type"`
	Content      string                 `json:"content"`       // YAML content
	ParsedConfig map[string]interface{} `json:"parsed_config"` // Parsed YAML structure
	ResolvedAt   time.Time              `json:"resolved_at"`
	GitRef       string                 `json:"git_ref"`   // Git reference if from git
	FilePath     string                 `json:"file_path"` // Original file path
	Metadata     map[string]interface{} `json:"metadata"`
}

ResolvedConfig represents a configuration after all inheritance is resolved

Jump to

Keyboard shortcuts

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