Documentation
¶
Overview ¶
Package config handles YAML configuration stored under the XDG config directory. Secrets are NEVER written to the config file — only base_url, spec_path, output, and timeout.
Configuration loading and saving is backed by spf13/viper, matching the design document. Viper provides file + env + defaults cascade and YAML (de)serialization out of the box.
Index ¶
Constants ¶
const ( DefaultOutput = "json" DefaultTimeout = 30 * time.Second )
Defaults applied when a value is missing.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
ConfigDir returns the resolved config directory honoring XDG. Order: $XDG_CONFIG_HOME/invgate-cli, else $HOME/.config/invgate-cli.
func ConfigPath ¶
ConfigPath returns the full path to config.yaml.
func DefaultSpecPath ¶
DefaultSpecPath returns the default location for a spec file under the config directory.
func RunSetup ¶
func RunSetup(opts SetupOptions) error
RunSetup guides the user through configuring invgate-cli. In interactive mode it downloads the spec, then prompts for base URL, credentials, and output format. In non-interactive mode it validates that required flags are set. On completion it writes the config file and stores secrets in the keychain, then tests the connection.
Types ¶
type Config ¶
type Config struct {
BaseURL string `yaml:"base_url"`
SpecPath string `yaml:"spec_path"`
Output string `yaml:"output"`
Timeout time.Duration `yaml:"timeout"`
}
Config holds the non-secret CLI configuration persisted to disk.
func Load ¶
Load reads the YAML config file (if it exists) and applies env var overrides via viper's automatic env lookup. Missing files are not errors — defaults are applied. Env vars always win over file values.
func LoadFromPath ¶
LoadFromPath loads a config from an explicit path (used in tests). Env vars still override file values via viper's automatic env.
func (*Config) Save ¶
Save writes the config to disk as YAML. Only non-secret fields are written. The config directory is created if it does not exist.
func (*Config) SaveToPath ¶
SaveToPath writes the config to an explicit path (used in tests).