Documentation
¶
Overview ¶
Package loader provides implementations of the confii.Loader interface for various configuration sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseContent ¶
ParseContent parses raw bytes into a config map based on format. Exported for use by cloud loaders.
Types ¶
type EnvFileLoader ¶
type EnvFileLoader struct {
// contains filtered or unexported fields
}
EnvFileLoader loads configuration from a .env file. Format: KEY=VALUE per line with support for comments, quoting, and nested keys.
func NewEnvFile ¶
func NewEnvFile(path string) *EnvFileLoader
NewEnvFile creates a new .env file loader. Defaults to ".env" if path is empty.
func (*EnvFileLoader) Load ¶
Load reads and parses the .env file at the configured path, returning key-value pairs as a configuration map.
func (*EnvFileLoader) Source ¶
func (l *EnvFileLoader) Source() string
Source returns the identifier for this loader's configuration source.
type EnvLoaderOption ¶
type EnvLoaderOption func(*EnvironmentLoader)
EnvLoaderOption configures the EnvironmentLoader.
func WithSeparator ¶
func WithSeparator(sep string) EnvLoaderOption
WithSeparator sets the nesting separator (default "__").
type EnvironmentLoader ¶
type EnvironmentLoader struct {
// contains filtered or unexported fields
}
EnvironmentLoader loads configuration from environment variables matching a prefix. Variables are stripped of the prefix, split on the separator to create nested keys, and lowercased.
func NewEnvironment ¶
func NewEnvironment(prefix string, opts ...EnvLoaderOption) *EnvironmentLoader
NewEnvironment creates a new environment variable loader. The prefix is uppercased automatically. The default separator is "__".
func (*EnvironmentLoader) Load ¶
Load reads environment variables matching the configured prefix and parses them into a nested configuration map.
func (*EnvironmentLoader) Source ¶
func (l *EnvironmentLoader) Source() string
Source returns the identifier for this loader's configuration source.
type HTTPLoader ¶
type HTTPLoader struct {
// contains filtered or unexported fields
}
HTTPLoader loads configuration from an HTTP/HTTPS endpoint.
func NewHTTP ¶
func NewHTTP(url string, opts ...HTTPOption) *HTTPLoader
NewHTTP creates a new HTTP loader for the given URL.
func (*HTTPLoader) Load ¶
Load fetches configuration from the HTTP/HTTPS endpoint at the configured URL and parses the response body.
func (*HTTPLoader) Source ¶
func (l *HTTPLoader) Source() string
Source returns the identifier for this loader's configuration source.
type HTTPOption ¶
type HTTPOption func(*HTTPLoader)
HTTPOption configures the HTTPLoader.
func WithBasicAuth ¶
func WithBasicAuth(username, password string) HTTPOption
WithBasicAuth sets HTTP basic auth credentials.
func WithHeaders ¶
func WithHeaders(h map[string]string) HTTPOption
WithHeaders sets HTTP headers for the request.
func WithTimeout ¶
func WithTimeout(d time.Duration) HTTPOption
WithTimeout sets the HTTP request timeout.
type INILoader ¶
type INILoader struct {
// contains filtered or unexported fields
}
INILoader loads configuration from an INI file. Each section becomes a top-level key; keys within sections are nested.
type JSONLoader ¶
type JSONLoader struct {
// contains filtered or unexported fields
}
JSONLoader loads configuration from a JSON file.
func NewJSON ¶
func NewJSON(path string) *JSONLoader
NewJSON creates a new JSON loader for the given file path.
func (*JSONLoader) Load ¶
Load reads and parses the JSON file at the configured path, returning the parsed configuration as a map.
func (*JSONLoader) Source ¶
func (l *JSONLoader) Source() string
Source returns the identifier for this loader's configuration source.
type TOMLLoader ¶
type TOMLLoader struct {
// contains filtered or unexported fields
}
TOMLLoader loads configuration from a TOML file.
func NewTOML ¶
func NewTOML(path string) *TOMLLoader
NewTOML creates a new TOML loader for the given file path.
func (*TOMLLoader) Load ¶
Load reads and parses the TOML file at the configured path, returning the parsed configuration as a map.
func (*TOMLLoader) Source ¶
func (l *TOMLLoader) Source() string
Source returns the identifier for this loader's configuration source.
type YAMLLoader ¶
type YAMLLoader struct {
// contains filtered or unexported fields
}
YAMLLoader loads configuration from a YAML file.
func NewYAML ¶
func NewYAML(path string) *YAMLLoader
NewYAML creates a new YAML loader for the given file path.
func (*YAMLLoader) Load ¶
Load reads and parses the YAML file at the configured path, returning the parsed configuration as a map.
func (*YAMLLoader) Source ¶
func (l *YAMLLoader) Source() string
Source returns the identifier for this loader's configuration source.