Documentation
¶
Overview ¶
Package file provides config loader support for xconfig
Index ¶
- func NewPlugin(path string, unmarshal Unmarshal, config Config, loader *Loader) plugins.Plugin
- func NewReader(src io.Reader, unmarshal Unmarshal) plugins.Plugin
- type Config
- type File
- type Loader
- func (f *Loader) AddFile(path string, optional bool) error
- func (f *Loader) AddFiles(paths []string, optional bool) error
- func (f *Loader) ClearUnknownFields()
- func (f *Loader) DisallowUnknownFields(disallow bool)
- func (f *Loader) GetUnknownFields() map[string][]string
- func (f *Loader) Plugins() []plugins.Plugin
- func (f *Loader) PresentFields() map[string]struct{}
- func (f *Loader) RegisterDecoder(format string, decoder Unmarshal) error
- type UnknownField
- type UnknownFieldsError
- type Unmarshal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// indicates if a file that does not exist should be ignored.
Optional bool
// indicates if unknown fields should cause an error.
DisallowUnknownFields bool
}
Config describes the options required for a file.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader represents a set of file paths and the appropriate unmarshal function for the given file.
func (*Loader) ClearUnknownFields ¶
func (f *Loader) ClearUnknownFields()
ClearUnknownFields clears the list of unknown fields.
func (*Loader) DisallowUnknownFields ¶
DisallowUnknownFields enables strict validation of configuration files. When enabled, loading will fail if any unknown fields are found.
func (*Loader) GetUnknownFields ¶
GetUnknownFields returns all unknown fields found in configuration files. Returns a map where keys are file paths and values are slices of unknown field paths.
func (*Loader) Plugins ¶
Plugins constructs a slice of Plugin from the Files list of paths and unmarshal functions.
func (*Loader) PresentFields ¶ added in v0.2.6
PresentFields returns a union set of all leaf field paths that were explicitly present in loaded configuration files.
type UnknownField ¶
type UnknownField struct {
Path string // Field path (e.g., "Database.Extra.Field")
File string // Source file path
}
UnknownField represents a single unknown field with its path and source file.
type UnknownFieldsError ¶
type UnknownFieldsError struct {
// Fields contains a map of file paths to their unknown fields
Fields map[string][]string
}
UnknownFieldsError represents an error when unknown fields are found in configuration files.
func (*UnknownFieldsError) Error ¶
func (e *UnknownFieldsError) Error() string
Error implements the error interface.