Documentation
¶
Overview ¶
Package customization provides functionality for identifying, preserving, and reapplying user customizations during template and module updates.
Index ¶
- type CustomizationEntry
- type CustomizationMarker
- type CustomizationType
- type Detector
- type DetectorOptions
- type PreservationPolicy
- type Preserver
- type PreserverOptions
- type Registry
- func (r *Registry) AddEntry(entry *CustomizationEntry)
- func (r *Registry) GetEntriesByComponentID(componentID string, entryType CustomizationType) []*CustomizationEntry
- func (r *Registry) GetEntriesByPath(path string, entryType CustomizationType) []*CustomizationEntry
- func (r *Registry) GetEntry(id string) *CustomizationEntry
- func (r *Registry) Load() error
- func (r *Registry) RemoveEntry(id string)
- func (r *Registry) Save() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomizationEntry ¶
type CustomizationEntry struct {
// ID is the unique identifier for the customization
ID string `json:"id"`
// Type is the type of customization
Type CustomizationType `json:"type"`
// Path is the path to the customized file, relative to the component root
Path string `json:"path"`
// ComponentID is the ID of the template or module
ComponentID string `json:"component_id"`
// BaseVersion is the version of the component that was customized
BaseVersion string `json:"base_version"`
// CustomizationDate is the date the customization was made
CustomizationDate time.Time `json:"customization_date"`
// Hash is the hash of the original file content
OriginalHash string `json:"original_hash"`
// CustomizedHash is the hash of the customized file content
CustomizedHash string `json:"customized_hash"`
// Markers contains the customization markers found in the file
Markers []CustomizationMarker `json:"markers,omitempty"`
// Policy is the preservation policy for this customization
Policy PreservationPolicy `json:"policy"`
}
CustomizationEntry represents a single customization entry in the registry
type CustomizationMarker ¶
type CustomizationMarker struct {
// Type is the type of marker
Type string `json:"type"`
// StartLine is the line number where the marker starts
StartLine int `json:"start_line"`
// EndLine is the line number where the marker ends
EndLine int `json:"end_line"`
// Content is the content of the marker
Content string `json:"content,omitempty"`
}
CustomizationMarker represents a marker for customization in a file
type CustomizationType ¶
type CustomizationType string
CustomizationType represents the type of customization
const ( // TemplateCustomization represents a customization to a template TemplateCustomization CustomizationType = "template" // ModuleCustomization represents a customization to a module ModuleCustomization CustomizationType = "module" )
type Detector ¶
type Detector struct {
// Registry is the customization registry
Registry *Registry
// BaseDir is the directory containing the original templates and modules
BaseDir string
// CustomizedDir is the directory containing the customized templates and modules
CustomizedDir string
}
Detector identifies user customizations in templates and modules
func NewDetector ¶
func NewDetector(options *DetectorOptions) (*Detector, error)
NewDetector creates a new customization detector
func (*Detector) DetectModuleCustomizations ¶
func (d *Detector) DetectModuleCustomizations() ([]*CustomizationEntry, error)
DetectModuleCustomizations detects customizations in modules
func (*Detector) DetectTemplateCustomizations ¶
func (d *Detector) DetectTemplateCustomizations() ([]*CustomizationEntry, error)
DetectTemplateCustomizations detects customizations in templates
func (*Detector) RegisterCustomizations ¶
RegisterCustomizations registers all detected customizations in the registry
type DetectorOptions ¶
type DetectorOptions struct {
// Registry is the customization registry
Registry *Registry
// BaseDir is the directory containing the original templates and modules
BaseDir string
// CustomizedDir is the directory containing the customized templates and modules
CustomizedDir string
}
DetectorOptions contains options for the Detector
type PreservationPolicy ¶
type PreservationPolicy string
PreservationPolicy represents the policy for preserving customizations
const ( // AlwaysPreserve means the customization should always be preserved AlwaysPreserve PreservationPolicy = "always_preserve" // PreserveWithConflictResolution means the customization should be preserved with conflict resolution PreserveWithConflictResolution PreservationPolicy = "preserve_with_conflict_resolution" // AskUser means the user should be asked what to do with the customization AskUser PreservationPolicy = "ask_user" // Discard means the customization should be discarded Discard PreservationPolicy = "discard" )
type Preserver ¶
type Preserver struct {
// Registry is the customization registry
Registry *Registry
// InstallDir is the directory where the tool is installed
InstallDir string
// BackupDir is the directory for backups during update
BackupDir string
// Logger is the logger for preserver operations
Logger *os.File
}
Preserver preserves and reapplies user customizations during updates
func NewPreserver ¶
func NewPreserver(options *PreserverOptions) (*Preserver, error)
NewPreserver creates a new customization preserver
func (*Preserver) PreserveModuleCustomizations ¶
PreserveModuleCustomizations preserves module customizations before update
func (*Preserver) PreserveTemplateCustomizations ¶
PreserveTemplateCustomizations preserves template customizations before update
func (*Preserver) ReapplyModuleCustomizations ¶
ReapplyModuleCustomizations reapplies module customizations after update
func (*Preserver) ReapplyTemplateCustomizations ¶
ReapplyTemplateCustomizations reapplies template customizations after update
type PreserverOptions ¶
type PreserverOptions struct {
// Registry is the customization registry
Registry *Registry
// InstallDir is the directory where the tool is installed
InstallDir string
// BackupDir is the directory for backups during update
BackupDir string
// LogFile is the file to log preserver operations
LogFile *os.File
}
PreserverOptions contains options for the Preserver
type Registry ¶
type Registry struct {
// Entries is a map of customization entries by ID
Entries map[string]*CustomizationEntry `json:"entries"`
// RegistryPath is the path to the registry file
RegistryPath string `json:"-"`
}
Registry represents the customization registry
func NewRegistry ¶
NewRegistry creates a new customization registry
func (*Registry) AddEntry ¶
func (r *Registry) AddEntry(entry *CustomizationEntry)
AddEntry adds a customization entry to the registry
func (*Registry) GetEntriesByComponentID ¶
func (r *Registry) GetEntriesByComponentID(componentID string, entryType CustomizationType) []*CustomizationEntry
GetEntriesByComponentID gets all customization entries for a component
func (*Registry) GetEntriesByPath ¶
func (r *Registry) GetEntriesByPath(path string, entryType CustomizationType) []*CustomizationEntry
GetEntriesByPath gets all customization entries for a path
func (*Registry) GetEntry ¶
func (r *Registry) GetEntry(id string) *CustomizationEntry
GetEntry gets a customization entry from the registry
func (*Registry) RemoveEntry ¶
RemoveEntry removes a customization entry from the registry