Documentation
¶
Overview ¶
Package config loads named datasources from config.toml, builds a datasource from MYSQL_* environment variables (compatible with the original MCP), and resolves a final datasource with precedence: CLI overrides > env > file > default.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrPlaceholderUnset = errors.New("placeholder env var unset")
ErrPlaceholderUnset is returned when a password ${ENV} placeholder references an unset env var.
View Source
var ErrUnknownDatasource = errors.New("unknown datasource")
ErrUnknownDatasource is returned when a named datasource cannot be found.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Datasources map[string]Datasource `toml:"datasource"`
DefaultDatasource string `toml:"default"`
}
Config is the parsed set of named datasources.
type Datasource ¶
type Datasource struct {
Host string
Port int
User string
Password string
Database string
SSLMode string
SSLCA string
ConnectTimeout int
SQLMode string
Charset string
Collation string
AuthPlugin string
SSH *SSHConfig
}
Datasource is a single MySQL connection target.
func FromEnv ¶
func FromEnv() (Datasource, error)
FromEnv returns a datasource from env vars (with defaults). Used for pure-env mode.
func Resolve ¶
func Resolve(cfg *Config, name string, overrides Datasource) (Datasource, error)
Resolve: flag > env > file > default.
Click to show internal directories.
Click to hide internal directories.