Documentation
¶
Overview ¶
Package config loads sqio configuration from defaults, TOML files, and environment variables.
Index ¶
- func DefaultPath() string
- func DefaultTOML() string
- func FindLocalPath(start string) (string, error)
- func RemoveConnection(path, name string) error
- func Save(path string, cfg Config) error
- func TimeoutDuration(cfg Config) (time.Duration, error)
- func UpsertConnection(path string, conn Connection) error
- type Config
- type Connection
- type FormatConfig
- type LintConfig
- type QueryConfig
- type SSHTunnel
- type ValidationIssue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the per-user global configuration path.
func DefaultTOML ¶
func DefaultTOML() string
DefaultTOML returns the template written by the init command.
func FindLocalPath ¶
FindLocalPath walks from start toward the filesystem root looking for the nearest sqio.toml. An empty start uses the current working directory.
func RemoveConnection ¶
RemoveConnection removes a named connection from path.
func TimeoutDuration ¶
TimeoutDuration parses the query timeout string into a time.Duration.
func UpsertConnection ¶
func UpsertConnection(path string, conn Connection) error
UpsertConnection adds or replaces a connection in path.
Types ¶
type Config ¶
type Config struct {
Theme string `toml:"theme"`
Editor string `toml:"editor"`
Query QueryConfig `toml:"query"`
Formatter FormatConfig `toml:"formatter"`
Lint LintConfig `toml:"lint"`
Connections []Connection `toml:"connections"`
}
Config is the top-level sqio configuration model.
func Default ¶
func Default() Config
Default returns sqio's built-in configuration before file and environment overrides are applied.
func Load ¶
Load reads configuration from path when provided, otherwise from the global config and the nearest local sqio.toml, then applies supported environment variable overrides.
func (Config) Connection ¶
func (cfg Config) Connection(name string) (Connection, error)
Connection returns the named configured connection.
type Connection ¶
type Connection struct {
Name string `toml:"name"`
Driver string `toml:"driver"`
Host string `toml:"host"`
Port int `toml:"port"`
Database string `toml:"database"`
User string `toml:"user"`
Password string `toml:"password"`
PasswordEncrypted bool `toml:"password_encrypted"`
Readonly bool `toml:"readonly"`
SSLMode string `toml:"sslmode"`
DSN string `toml:"dsn"`
SSHTunnel SSHTunnel `toml:"ssh_tunnel"`
}
Connection describes a named database connection from configuration.
type FormatConfig ¶
type FormatConfig struct {
Dialect string `toml:"dialect"`
KeywordCase string `toml:"keyword_case"`
IdentifierCase string `toml:"identifier_case"`
Indent int `toml:"indent"`
LineWidth int `toml:"line_width"`
}
FormatConfig controls SQL formatter defaults.
type LintConfig ¶
type LintConfig struct {
Level string `toml:"level"`
Enable []string `toml:"enable"`
Disable []string `toml:"disable"`
}
LintConfig controls SQL lint rule filtering.
type QueryConfig ¶
type QueryConfig struct {
Timeout string `toml:"timeout"`
MaxRows int `toml:"max_rows"`
Format string `toml:"format"`
}
QueryConfig controls SQL execution defaults.
type SSHTunnel ¶
type SSHTunnel struct {
Enabled bool `toml:"enabled"`
Host string `toml:"host"`
Port int `toml:"port"`
User string `toml:"user"`
Password string `toml:"password"`
PrivateKey string `toml:"private_key"`
KnownHosts string `toml:"known_hosts"`
KeepAlive string `toml:"keepalive"`
Reconnect bool `toml:"reconnect"`
ReconnectAttempts int `toml:"reconnect_attempts"`
JumpHost string `toml:"jump_host"`
JumpPort int `toml:"jump_port"`
JumpUser string `toml:"jump_user"`
JumpPassword string `toml:"jump_password"`
JumpPrivateKey string `toml:"jump_private_key"`
JumpKnownHosts string `toml:"jump_known_hosts"`
}
SSHTunnel describes optional SSH forwarding settings for a connection.
type ValidationIssue ¶
ValidationIssue describes a configuration problem that can be reported without opening database connections.
func Validate ¶
func Validate(cfg Config) []ValidationIssue
Validate checks static configuration fields without opening database connections or decrypting secrets.