Documentation
¶
Index ¶
- Variables
- func DetectTOMLFormat(data []byte) bool
- func ExtractComments(data []byte) ([]string, error)
- func FormatYAML(data []byte) ([]byte, error)
- func MergeYAMLDocuments(documents ...map[string]interface{}) (map[string]interface{}, error)
- func ValidateYAMLSyntax(data []byte) error
- type DataTransformer
- type EnvVarTransformer
- type FormatProcessor
- func GetProcessor(logger logger.Logger) FormatProcessor
- func GetStrictProcessor(logger logger.Logger) FormatProcessor
- func NewJSONProcessor() FormatProcessor
- func NewJSONProcessorWithOptions(options JSONOptions) FormatProcessor
- func NewYAMLProcessor() FormatProcessor
- func NewYAMLProcessorWithOptions(options YAMLOptions) FormatProcessor
- type JSONOptions
- type JSONProcessor
- func (p *JSONProcessor) Compact(data []byte) ([]byte, error)
- func (p *JSONProcessor) ConvertToJSONSchema(data map[string]interface{}) (map[string]interface{}, error)
- func (p *JSONProcessor) Extensions() []string
- func (p *JSONProcessor) ExtractPaths(data map[string]interface{}) []string
- func (p *JSONProcessor) FormatJSON(data []byte, indent string) ([]byte, error)
- func (p *JSONProcessor) GetMetadata() map[string]interface{}
- func (p *JSONProcessor) GetOptions() JSONOptions
- func (p *JSONProcessor) GetValueByPath(data map[string]interface{}, path string) (interface{}, error)
- func (p *JSONProcessor) Marshal(data map[string]interface{}) ([]byte, error)
- func (p *JSONProcessor) MarshalIndent(data map[string]interface{}, prefix, indent string) ([]byte, error)
- func (p *JSONProcessor) Name() string
- func (p *JSONProcessor) Parse(data []byte) (map[string]interface{}, error)
- func (p *JSONProcessor) SetOptions(options JSONOptions)
- func (p *JSONProcessor) Validate(data map[string]interface{}) error
- func (p *JSONProcessor) ValidateJSONSyntax(data []byte) error
- type LoadOptions
- type LoadResult
- type Loader
- func (l *Loader) ClearCache()
- func (l *Loader) GetCacheStats() map[string]interface{}
- func (l *Loader) GetProcessor(name string) (FormatProcessor, bool)
- func (l *Loader) GetProcessorByExtension(extension string) (FormatProcessor, bool)
- func (l *Loader) LoadSource(ctx context.Context, source configcore.ConfigSource) (map[string]interface{}, error)
- func (l *Loader) LoadSourceWithOptions(ctx context.Context, source configcore.ConfigSource, options LoadOptions) (map[string]interface{}, error)
- func (l *Loader) RegisterProcessor(processor FormatProcessor)
- type LoaderConfig
- type MergeStrategy
- type SecretsTransformer
- type TOMLFormatValidator
- type TOMLProcessor
- func (tp *TOMLProcessor) Extensions() []string
- func (tp *TOMLProcessor) FormatData(data map[string]interface{}) ([]byte, error)
- func (tp *TOMLProcessor) Name() string
- func (tp *TOMLProcessor) Parse(data []byte) (map[string]interface{}, error)
- func (tp *TOMLProcessor) ParseToStruct(data []byte, target interface{}) error
- func (tp *TOMLProcessor) Validate(data map[string]interface{}) error
- func (tp *TOMLProcessor) ValidateStructTags(target interface{}) error
- type TOMLProcessorOptions
- type YAMLOptions
- type YAMLProcessor
- func (p *YAMLProcessor) Extensions() []string
- func (p *YAMLProcessor) GetMetadata() map[string]interface{}
- func (p *YAMLProcessor) GetOptions() YAMLOptions
- func (p *YAMLProcessor) Marshal(data map[string]interface{}) ([]byte, error)
- func (p *YAMLProcessor) MarshalIndent(data map[string]interface{}, indent string) ([]byte, error)
- func (p *YAMLProcessor) Name() string
- func (p *YAMLProcessor) Parse(data []byte) (map[string]interface{}, error)
- func (p *YAMLProcessor) ParseMultiDocument(data []byte) ([]map[string]interface{}, error)
- func (p *YAMLProcessor) SetOptions(options YAMLOptions)
- func (p *YAMLProcessor) Validate(data map[string]interface{}) error
- func (p *YAMLProcessor) ValidateWithSchema(data map[string]interface{}, schema interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfigError = errors.ErrConfigError ErrValidationError = errors.ErrValidationError )
Functions ¶
func DetectTOMLFormat ¶
DetectTOMLFormat attempts to detect if data is in TOML format
func ExtractComments ¶
ExtractComments extracts comments from YAML content
func FormatYAML ¶
FormatYAML formats YAML content with consistent indentation
func MergeYAMLDocuments ¶
MergeYAMLDocuments merges multiple YAML documents
func ValidateYAMLSyntax ¶
ValidateYAMLSyntax validates YAML syntax without full parsing
Types ¶
type DataTransformer ¶
type DataTransformer interface {
Name() string
Transform(data map[string]interface{}) (map[string]interface{}, error)
Priority() int
}
DataTransformer transforms configuration data during loading
type EnvVarTransformer ¶
type EnvVarTransformer struct{}
EnvVarTransformer transforms environment variable references
func (*EnvVarTransformer) Name ¶
func (t *EnvVarTransformer) Name() string
func (*EnvVarTransformer) Priority ¶
func (t *EnvVarTransformer) Priority() int
type FormatProcessor ¶
type FormatProcessor interface {
Name() string
Extensions() []string
Parse(data []byte) (map[string]interface{}, error)
Validate(data map[string]interface{}) error
}
FormatProcessor processes specific configuration formats
func GetProcessor ¶
func GetProcessor(logger logger.Logger) FormatProcessor
GetProcessor returns a configured TOML processor
func GetStrictProcessor ¶
func GetStrictProcessor(logger logger.Logger) FormatProcessor
GetStrictProcessor returns a strict TOML processor
func NewJSONProcessor ¶
func NewJSONProcessor() FormatProcessor
NewJSONProcessor creates a new JSON processor
func NewJSONProcessorWithOptions ¶
func NewJSONProcessorWithOptions(options JSONOptions) FormatProcessor
NewJSONProcessorWithOptions creates a new JSON processor with options
func NewYAMLProcessor ¶
func NewYAMLProcessor() FormatProcessor
NewYAMLProcessor creates a new YAML processor
func NewYAMLProcessorWithOptions ¶
func NewYAMLProcessorWithOptions(options YAMLOptions) FormatProcessor
NewYAMLProcessorWithOptions creates a new YAML processor with options
type JSONOptions ¶
type JSONOptions struct {
Strict bool // Strict parsing mode
AllowComments bool // Allow comments in JSON (JSON5 style)
AllowTrailingCommas bool // Allow trailing commas
ValidateSchema bool // Validate against JSON schema
RequiredFields []string // List of required fields
DeprecatedFields map[string]string // Deprecated field mappings
NumberAsString bool // Parse numbers as strings to preserve precision
DisallowUnknown bool // Disallow unknown fields
}
JSONOptions contains options for JSON processing
type JSONProcessor ¶
type JSONProcessor struct {
// contains filtered or unexported fields
}
JSONProcessor implements JSON format processing
func (*JSONProcessor) Compact ¶
func (p *JSONProcessor) Compact(data []byte) ([]byte, error)
Compact compacts JSON by removing whitespace
func (*JSONProcessor) ConvertToJSONSchema ¶
func (p *JSONProcessor) ConvertToJSONSchema(data map[string]interface{}) (map[string]interface{}, error)
ConvertToJSONSchema converts a configuration map to a JSON schema
func (*JSONProcessor) Extensions ¶
func (p *JSONProcessor) Extensions() []string
Extensions returns supported file extensions
func (*JSONProcessor) ExtractPaths ¶
func (p *JSONProcessor) ExtractPaths(data map[string]interface{}) []string
ExtractPaths extracts all JSON paths from the data
func (*JSONProcessor) FormatJSON ¶
func (p *JSONProcessor) FormatJSON(data []byte, indent string) ([]byte, error)
FormatJSON formats JSON content with consistent indentation
func (*JSONProcessor) GetMetadata ¶
func (p *JSONProcessor) GetMetadata() map[string]interface{}
GetMetadata returns metadata about the JSON processor
func (*JSONProcessor) GetOptions ¶
func (p *JSONProcessor) GetOptions() JSONOptions
GetOptions returns the current processor options
func (*JSONProcessor) GetValueByPath ¶
func (p *JSONProcessor) GetValueByPath(data map[string]interface{}, path string) (interface{}, error)
GetValueByPath gets a value using a JSON path
func (*JSONProcessor) Marshal ¶
func (p *JSONProcessor) Marshal(data map[string]interface{}) ([]byte, error)
Marshal marshals a configuration map to JSON
func (*JSONProcessor) MarshalIndent ¶
func (p *JSONProcessor) MarshalIndent(data map[string]interface{}, prefix, indent string) ([]byte, error)
MarshalIndent marshals a configuration map to indented JSON
func (*JSONProcessor) Parse ¶
func (p *JSONProcessor) Parse(data []byte) (map[string]interface{}, error)
Parse parses JSON data into a configuration map
func (*JSONProcessor) SetOptions ¶
func (p *JSONProcessor) SetOptions(options JSONOptions)
SetOptions updates the processor options
func (*JSONProcessor) Validate ¶
func (p *JSONProcessor) Validate(data map[string]interface{}) error
Validate validates a configuration map against JSON rules
func (*JSONProcessor) ValidateJSONSyntax ¶
func (p *JSONProcessor) ValidateJSONSyntax(data []byte) error
ValidateJSONSyntax validates JSON syntax without full parsing
type LoadOptions ¶
type LoadOptions struct {
UseCache bool
ValidateFormat bool
ExpandEnvVars bool
ExpandSecrets bool
MergeStrategy MergeStrategy
Transformers []DataTransformer
}
LoadOptions contains options for loading configuration
type LoadResult ¶
type LoadResult struct {
Data map[string]interface{}
Source string
LoadTime time.Time
Size int
Format string
Hash string
Error error
Cached bool
}
LoadResult represents the result of loading configuration
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading configuration from various sources
func NewLoader ¶
func NewLoader(config LoaderConfig) *Loader
NewLoader creates a new configuration loader
func (*Loader) GetCacheStats ¶
GetCacheStats returns cache statistics
func (*Loader) GetProcessor ¶
func (l *Loader) GetProcessor(name string) (FormatProcessor, bool)
GetProcessor returns a format processor by name
func (*Loader) GetProcessorByExtension ¶
func (l *Loader) GetProcessorByExtension(extension string) (FormatProcessor, bool)
GetProcessorByExtension returns a format processor by file extension
func (*Loader) LoadSource ¶
func (l *Loader) LoadSource(ctx context.Context, source configcore.ConfigSource) (map[string]interface{}, error)
LoadSource loads configuration from a source
func (*Loader) LoadSourceWithOptions ¶
func (l *Loader) LoadSourceWithOptions(ctx context.Context, source configcore.ConfigSource, options LoadOptions) (map[string]interface{}, error)
LoadSourceWithOptions loads configuration from a source with options
func (*Loader) RegisterProcessor ¶
func (l *Loader) RegisterProcessor(processor FormatProcessor)
RegisterProcessor registers a format processor
type LoaderConfig ¶
type LoaderConfig struct {
CacheTTL time.Duration
RetryCount int
RetryDelay time.Duration
Logger logger.Logger
Metrics shared.Metrics
ErrorHandler shared.ErrorHandler
}
LoaderConfig contains configuration for the loader
type MergeStrategy ¶
type MergeStrategy string
MergeStrategy defines how to merge configuration data
const ( MergeStrategyOverride MergeStrategy = "override" // Override existing values MergeStrategyMerge MergeStrategy = "merge" // Deep merge objects MergeStrategyAppend MergeStrategy = "append" // Append to arrays MergeStrategyPreserve MergeStrategy = "preserve" // Preserve existing values )
type SecretsTransformer ¶
type SecretsTransformer struct {
// contains filtered or unexported fields
}
SecretsTransformer transforms secret references
func (*SecretsTransformer) Name ¶
func (t *SecretsTransformer) Name() string
func (*SecretsTransformer) Priority ¶
func (t *SecretsTransformer) Priority() int
type TOMLFormatValidator ¶
type TOMLFormatValidator struct {
// contains filtered or unexported fields
}
TOMLFormatValidator provides additional validation for TOML-specific features
func NewTOMLFormatValidator ¶
func NewTOMLFormatValidator(processor *TOMLProcessor) *TOMLFormatValidator
NewTOMLFormatValidator creates a new TOML format validator
func (*TOMLFormatValidator) ValidateTableStructure ¶
func (tv *TOMLFormatValidator) ValidateTableStructure(data map[string]interface{}) error
ValidateTableStructure validates TOML table structure
type TOMLProcessor ¶
type TOMLProcessor struct {
// contains filtered or unexported fields
}
TOMLProcessor handles TOML format configuration files
func NewTOMLProcessor ¶
func NewTOMLProcessor(options TOMLProcessorOptions) *TOMLProcessor
NewTOMLProcessor creates a new TOML format processor
func (*TOMLProcessor) Extensions ¶
func (tp *TOMLProcessor) Extensions() []string
Extensions returns the file extensions handled by this processor
func (*TOMLProcessor) FormatData ¶
func (tp *TOMLProcessor) FormatData(data map[string]interface{}) ([]byte, error)
FormatData formats configuration data as TOML
func (*TOMLProcessor) Parse ¶
func (tp *TOMLProcessor) Parse(data []byte) (map[string]interface{}, error)
Parse parses TOML data into a configuration map
func (*TOMLProcessor) ParseToStruct ¶
func (tp *TOMLProcessor) ParseToStruct(data []byte, target interface{}) error
ParseToStruct parses TOML data directly into a struct
func (*TOMLProcessor) Validate ¶
func (tp *TOMLProcessor) Validate(data map[string]interface{}) error
Validate validates TOML configuration data
func (*TOMLProcessor) ValidateStructTags ¶
func (tp *TOMLProcessor) ValidateStructTags(target interface{}) error
ValidateStructTags validates TOML struct tags in a target struct
type TOMLProcessorOptions ¶
type TOMLProcessorOptions struct {
Logger logger.Logger
StrictMode bool // Strict parsing mode
AllowUnknown bool // Allow unknown fields during validation
}
TOMLProcessorOptions contains options for the TOML processor
type YAMLOptions ¶
type YAMLOptions struct {
Strict bool // Strict parsing mode
AllowDuplicates bool // Allow duplicate keys
ValidateSchema bool // Validate against JSON schema
KnownFields bool // Only allow known fields
RequiredFields []string // List of required fields
DeprecatedFields map[string]string // Deprecated field mappings
}
YAMLOptions contains options for YAML processing
type YAMLProcessor ¶
type YAMLProcessor struct {
// contains filtered or unexported fields
}
YAMLProcessor implements YAML format processing
func (*YAMLProcessor) Extensions ¶
func (p *YAMLProcessor) Extensions() []string
Extensions returns supported file extensions
func (*YAMLProcessor) GetMetadata ¶
func (p *YAMLProcessor) GetMetadata() map[string]interface{}
GetMetadata returns metadata about the YAML processor
func (*YAMLProcessor) GetOptions ¶
func (p *YAMLProcessor) GetOptions() YAMLOptions
GetOptions returns the current processor options
func (*YAMLProcessor) Marshal ¶
func (p *YAMLProcessor) Marshal(data map[string]interface{}) ([]byte, error)
Marshal marshals a configuration map to YAML
func (*YAMLProcessor) MarshalIndent ¶
func (p *YAMLProcessor) MarshalIndent(data map[string]interface{}, indent string) ([]byte, error)
MarshalIndent marshals a configuration map to indented YAML
func (*YAMLProcessor) Parse ¶
func (p *YAMLProcessor) Parse(data []byte) (map[string]interface{}, error)
Parse parses YAML data into a configuration map
func (*YAMLProcessor) ParseMultiDocument ¶
func (p *YAMLProcessor) ParseMultiDocument(data []byte) ([]map[string]interface{}, error)
ParseMultiDocument parses multi-document YAML
func (*YAMLProcessor) SetOptions ¶
func (p *YAMLProcessor) SetOptions(options YAMLOptions)
SetOptions updates the processor options
func (*YAMLProcessor) Validate ¶
func (p *YAMLProcessor) Validate(data map[string]interface{}) error
Validate validates a configuration map against YAML rules
func (*YAMLProcessor) ValidateWithSchema ¶
func (p *YAMLProcessor) ValidateWithSchema(data map[string]interface{}, schema interface{}) error
ValidateWithSchema validates YAML against a JSON schema