Documentation
¶
Overview ¶
Package config persists non-secret CLI configuration and resolves the API URL via a deterministic layered priority chain.
Resolution order for the API URL (highest priority first):
- --api-url flag
- DBGORILLA_API_URL env var
- $XDG_CONFIG_HOME/dbgorilla/cli.toml (per-user; defaults to ~/.config/dbgorilla/cli.toml when XDG_CONFIG_HOME is unset)
- /etc/dbgorilla/cli.toml (system-wide; macOS uses /Library/Application Support/dbgorilla/cli.toml)
- (no default; caller surfaces a helpful error pointing at `dbg config`)
The user-config location follows the XDG Base Directory spec rather than a proprietary dotfile dir. Dotfile-walking credential stealers find both anyway, and XDG alignment lets backup/sync tooling treat dbg like every other modern CLI.
On-prem deployments don't share a single canonical URL, so we deliberately do not bake one in. The install script (scripts/install.sh.tmpl) writes the user-level config file at install time so the dev never has to type the URL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
Dir returns the per-user config directory (XDG-aware), creating it if needed. On Unix-like systems this is $XDG_CONFIG_HOME/dbgorilla, defaulting to ~/.config/dbgorilla. On Windows it's whatever os.UserConfigDir returns (typically %AppData%\dbgorilla).
func ResolveInsecure ¶
ResolveInsecure returns whether TLS verification should be skipped.
If the --insecure flag was explicitly set on the command line, that wins (including --insecure=false to deliberately override a persisted true). Otherwise falls back to user-config api.insecure, then system-config. flagSet should come from cmd.Flags().Changed("insecure").
func SystemConfigPath ¶
func SystemConfigPath() string
SystemConfigPath returns the OS-appropriate system-wide config path used by MDM-deployed configurations. This file is read-only from the CLI's point of view; we never write it.
func UserConfigPath ¶
UserConfigPath returns the per-user config file path.
Types ¶
type Config ¶
type Config struct {
API APIConfig `toml:"api"`
}
Config is the persisted CLI configuration.
func LoadSystem ¶
LoadSystem reads the system-wide config. A missing file returns a zero-value Config and nil error -- system config is optional.
func LoadUser ¶
LoadUser reads the per-user config. A missing file returns a zero-value Config and nil error.
type ResolvedSource ¶
type ResolvedSource string
ResolvedSource describes where the resolved API URL came from. Useful for `dbg config get api-url` so users can see exactly which layer won.
const ( SourceFlag ResolvedSource = "flag" SourceEnv ResolvedSource = "env" SourceUser ResolvedSource = "user-config" SourceSystem ResolvedSource = "system-config" SourceNone ResolvedSource = "none" )
func ResolveAPIURL ¶
func ResolveAPIURL(flagValue string) (string, ResolvedSource)
ResolveAPIURL returns the API URL using the documented layered priority. Returns the URL plus the source it came from. Empty URL + SourceNone means nothing is configured and the caller should error with a helpful message.