Documentation
¶
Index ¶
- Constants
- type DaselFileParser
- func (p *DaselFileParser) Put(data *map[string]any, path string, value any) error
- func (p *DaselFileParser) Read(path string) (any, Format, error)
- func (p *DaselFileParser) ReadWithFormat(path string, explicitFormat string) (any, Format, error)
- func (p *DaselFileParser) Select(data any, path string) (any, error)
- func (p *DaselFileParser) UpdateTOMLValue(filePath string, path string, newValue string) error
- func (p *DaselFileParser) Write(path string, data any, format Format) error
- type FileParser
- type FileUpdater
- type Format
- type Updater
Constants ¶
const ( ErrFileNotFound = "file not found" ErrPathNotFound = "path not found in file" ErrInvalidSelector = "invalid selector syntax" ErrUnsupportedFormat = "unsupported file format" ErrFileParseFailed = "failed to parse file" ErrFileWriteFailed = "failed to write file" ErrTemplateRender = "failed to render template" )
Error messages
const ( LogFileUpdated = "file_updated" LogUpdateSkipped = "update_skipped" LogUpdatesApplied = "updates_applied" LogValidatingConfig = "validating_update_config" )
Log messages for structured logging
const FilePermission os.FileMode = 0644
FilePermission is the default permission for written files
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DaselFileParser ¶
type DaselFileParser struct{}
DaselFileParser implements FileParser using dasel for path queries
func NewDaselFileParser ¶
func NewDaselFileParser() *DaselFileParser
NewDaselFileParser creates a new DaselFileParser
func (*DaselFileParser) Read ¶
func (p *DaselFileParser) Read(path string) (any, Format, error)
Read reads and parses a structured file
func (*DaselFileParser) ReadWithFormat ¶
ReadWithFormat reads a file using an explicit format
func (*DaselFileParser) Select ¶
func (p *DaselFileParser) Select(data any, path string) (any, error)
Select retrieves a value at the given path using dasel syntax
func (*DaselFileParser) UpdateTOMLValue ¶
func (p *DaselFileParser) UpdateTOMLValue(filePath string, path string, newValue string) error
UpdateTOMLValue does a targeted value replacement in a TOML file, preserving comments, ordering, and formatting. Parses to find the old value at the path, then replaces it in the raw bytes.
type FileParser ¶
type FileParser interface {
// Read reads and parses a structured file, returning the data and detected format
Read(filepath string) (any, Format, error)
// Write writes data back to file in the specified format
Write(filepath string, data any, format Format) error
// Select retrieves a value at the given path using dasel syntax
Select(data any, path string) (any, error)
// Put updates a value at the given path using dasel syntax
Put(data *map[string]any, path string, value any) error
}
FileParser provides operations on structured files (JSON, YAML, TOML)
type FileUpdater ¶
type FileUpdater interface {
// UpdateFiles applies all configured updates using the given template data
UpdateFiles(data emit.TemplateData) error
// ValidateConfig checks all update configurations are valid
ValidateConfig() error
// GetFilesToCommit returns list of files that were modified
GetFilesToCommit() []string
}
FileUpdater defines the interface for file update operations
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater implements FileUpdater with actual file operations
func NewUpdater ¶
func NewUpdater(configs []config.UpdateConfig, parser *DaselFileParser, logger *zap.Logger) *Updater
NewUpdater creates an Updater (IoC constructor accepting dependencies)
func NewUpdaterDefault ¶
func NewUpdaterDefault(configs []config.UpdateConfig) (*Updater, error)
NewUpdaterDefault creates an Updater with default dependencies This is excluded from unit test coverage as it's tested via integration tests
func (*Updater) GetFilesToCommit ¶
GetFilesToCommit returns list of files that were modified
func (*Updater) UpdateFiles ¶
func (u *Updater) UpdateFiles(data emit.TemplateData) error
UpdateFiles applies all configured updates using the given template data
func (*Updater) ValidateConfig ¶
ValidateConfig checks all update configurations are valid