Documentation
¶
Index ¶
- func DeleteProfile(configPath, name string) *errors.XError
- func DeleteSSHProxy(configPath, name string) *errors.XError
- func FindConfigPath(opts Options) string
- func InitConfig(path string) (string, *errors.XError)
- func SaveAI(configPath string, ai AIConfig) *errors.XError
- func SaveProfile(configPath, name string, p Profile) *errors.XError
- func SaveSSHProxy(configPath, name string, sp SSHProxy) *errors.XError
- func SetConfigValue(configPath, key, value string) *errors.XError
- type AIConfig
- type File
- type MCPConfig
- type MCPHTTPConfig
- type Options
- type Profile
- type ProfileInfo
- type Resolved
- type SSHProxy
- type WebConfig
- type WebHTTPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteProfile ¶ added in v1.1.0
DeleteProfile deletes a profile from the specified config file.
func DeleteSSHProxy ¶ added in v1.1.0
DeleteSSHProxy deletes an SSH proxy from the specified config file.
func FindConfigPath ¶ added in v0.0.10
FindConfigPath returns the path to the config file being used (or default path).
func InitConfig ¶ added in v0.0.10
InitConfig creates a template config file at the given path. If path is empty, uses the default path ($HOME/.config/xsql/xsql.yaml).
func SaveAI ¶ added in v1.20.0
SaveAI creates or updates the AI configuration in the specified config file.
func SaveProfile ¶ added in v1.1.0
SaveProfile creates or updates a profile in the specified config file.
func SaveSSHProxy ¶ added in v1.1.0
SaveSSHProxy creates or updates an SSH proxy in the specified config file.
func SetConfigValue ¶ added in v0.0.10
SetConfigValue sets a value in the config file using dot-notation key. Supported key patterns:
- profile.<name>.<field>
- ssh_proxy.<name>.<field>
Types ¶
type AIConfig ¶ added in v1.20.0
type AIConfig struct {
Provider string `yaml:"provider" json:"provider"` // default "openai"
BaseURL string `yaml:"base_url" json:"base_url"` // default "https://api.openai.com/v1"
APIKey string `yaml:"api_key" json:"api_key"` // supports keyring:xxx reference
AllowPlaintext bool `yaml:"allow_plaintext" json:"allow_plaintext"` // allow plaintext API key
Model string `yaml:"model" json:"model"` // default "gpt-4o"
MaxTokens int `yaml:"max_tokens" json:"max_tokens"` // default 8192
}
AIConfig defines the AI LLM service configuration.
type File ¶
type File struct {
SSHProxies map[string]SSHProxy `yaml:"ssh_proxies" json:"ssh_proxies"`
Profiles map[string]Profile `yaml:"profiles" json:"profiles"`
MCP MCPConfig `yaml:"mcp" json:"mcp"`
Web WebConfig `yaml:"web" json:"web"`
Stats stats.StatsConfig `yaml:"stats" json:"stats"`
AI AIConfig `yaml:"ai" json:"ai"`
}
File represents the xsql.yaml configuration structure. Constraint: config priority is CLI > ENV > Config.
type MCPConfig ¶ added in v0.0.6
type MCPConfig struct {
Transport string `yaml:"transport" json:"transport"` // stdio | streamable_http
HTTP MCPHTTPConfig `yaml:"http" json:"http"`
}
MCPConfig defines the MCP server configuration.
type MCPHTTPConfig ¶ added in v0.0.6
type MCPHTTPConfig struct {
Addr string `yaml:"addr" json:"addr"`
AuthToken string `yaml:"auth_token" json:"auth_token"` // supports keyring:xxx reference
AllowPlaintextToken bool `yaml:"allow_plaintext_token" json:"allow_plaintext_token"` // allow plaintext token
}
MCPHTTPConfig defines the MCP Streamable HTTP transport configuration.
type Options ¶
type Options struct {
// ConfigPath: if non-empty, only this file is read (error if not found).
ConfigPath string
// CLI
CLIProfile string
CLIProfileSet bool
CLIFormat string
CLIFormatSet bool
// CLI AI
CLIAIModel string
CLIAIModelSet bool
CLIAIBaseURL string
CLIAIBaseURLSet bool
CLIAIAPIKey string
CLIAIAPIKeySet bool
// ENV (injected by caller for testability)
EnvProfile string
EnvFormat string
EnvAIModel string
EnvAIBaseURL string
EnvAIAPIKey string
// HomeDir is used for default path resolution (auto-detected if empty).
HomeDir string
// WorkDir is used for default paths (falls back to process cwd if empty).
WorkDir string
}
type Profile ¶
type Profile struct {
Description string `yaml:"description" json:"description"` // description to distinguish databases
Format string `yaml:"format" json:"format"`
// DB connection
DB string `yaml:"db" json:"db"` // mysql | pg
DSN string `yaml:"dsn" json:"dsn"` // raw DSN (takes precedence)
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
User string `yaml:"user" json:"user"`
Password string `yaml:"password" json:"password"` // supports keyring:xxx reference
Database string `yaml:"database" json:"database"`
// Security options
AllowPlaintext bool `yaml:"allow_plaintext" json:"allow_plaintext"` // allow plaintext password
UnsafeAllowWrite bool `yaml:"unsafe_allow_write" json:"unsafe_allow_write"` // permit write-capable entrypoints; CLI also requires its runtime flag
// Timeout settings (seconds)
QueryTimeout int `yaml:"query_timeout" json:"query_timeout"` // query timeout, default 30s
SchemaTimeout int `yaml:"schema_timeout" json:"schema_timeout"` // schema export timeout, default 60s
// SSH proxy reference (refers to a name defined in ssh_proxies)
SSHProxy string `yaml:"ssh_proxy" json:"ssh_proxy"`
// Local port for the proxy (used by xsql proxy command)
LocalPort int `yaml:"local_port" json:"local_port"`
// Resolved SSH config (populated by Resolve, not read from YAML)
SSHConfig *SSHProxy `yaml:"-" json:"-"`
}
type ProfileInfo ¶ added in v0.0.10
type ProfileInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
DB string `json:"db"`
Mode string `json:"mode"` // "read-only" or "read-write"
}
func ProfileToInfo ¶ added in v0.0.10
func ProfileToInfo(name string, p Profile) ProfileInfo
type Resolved ¶
type SSHProxy ¶
type SSHProxy struct {
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
User string `yaml:"user" json:"user"`
IdentityFile string `yaml:"identity_file" json:"identity_file"`
Passphrase string `yaml:"passphrase" json:"passphrase"` // supports keyring:xxx reference
KnownHostsFile string `yaml:"known_hosts_file" json:"known_hosts_file"`
SkipHostKey bool `yaml:"skip_host_key" json:"skip_host_key"` // strongly discouraged
}
SSHProxy defines a reusable SSH proxy configuration.
type WebConfig ¶ added in v1.0.0
type WebConfig struct {
HTTP WebHTTPConfig `yaml:"http" json:"http"`
}
WebConfig defines the local web server configuration.
type WebHTTPConfig ¶ added in v1.0.0
type WebHTTPConfig struct {
Addr string `yaml:"addr" json:"addr"`
AuthToken string `yaml:"auth_token" json:"auth_token"` // supports keyring:xxx reference
AllowPlaintextToken bool `yaml:"allow_plaintext_token" json:"allow_plaintext_token"` // allow plaintext token
}
WebHTTPConfig defines the web HTTP transport configuration.