Documentation
¶
Overview ¶
Package config loads and saves the CLI's configuration: named contexts in config.yaml (shareable) and secrets in credentials.yaml (0600), both under $XDG_CONFIG_HOME/webtor (~/.config/webtor by default). The WEBTOR_* env vars override everything, so CI can run without any files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load() (*Config, Credentials, error)
Load reads config.yaml and credentials.yaml. A missing config is an error; missing credentials are not (an empty set is returned).
func Save ¶
func Save(cfg *Config, creds Credentials) error
Save writes both files, creating the directory as needed. credentials.yaml is written 0600 — it holds keys.
func SetCredentials ¶
func SetCredentials(name string, c ContextCredentials) error
SetCredentials updates one context's secrets on disk, preserving the rest.
Types ¶
type BackendName ¶
type BackendName string
BackendName is the config-file spelling of a backend kind.
const ( BackendWebUI BackendName = "webui" BackendRapidAPI BackendName = "rapidapi" BackendDirect BackendName = "direct" )
type Config ¶
type Config struct {
Current string `yaml:"current"`
Contexts map[string]Context `yaml:"contexts"`
}
Config is config.yaml: the contexts and which one is current.
type Context ¶
type Context struct {
Backend BackendName `yaml:"backend"`
// BaseURL overrides the backend's default endpoint. Required for direct.
BaseURL string `yaml:"base_url,omitempty"`
}
Context is one named backend configuration.
type ContextCredentials ¶
type ContextCredentials struct {
// APIKey is the web-ui API key, the RapidAPI key, or direct's
// pass-through api-key, depending on the context's backend.
APIKey string `yaml:"api_key,omitempty"`
// Token is direct's pass-through JWT.
Token string `yaml:"token,omitempty"`
}
ContextCredentials are the secrets of one context.
type Credentials ¶
type Credentials map[string]*ContextCredentials
Credentials is credentials.yaml: per-context secrets, kept out of the shareable config file.
type Resolved ¶
type Resolved struct {
Name string
Context Context
Creds ContextCredentials
// FromEnv marks the config-less WEBTOR_BACKEND mode: nothing is stored
// on disk for this configuration.
FromEnv bool
}
Resolved is a fully resolved runtime configuration: the chosen context plus its secrets, after env overrides.