Documentation
¶
Overview ¶
Package serverconfig resolves the gemba server URL for CLI verbs.
gm-o9t8.1.1.3 — single, documented precedence order for every CLI command that talks to a gemba server. Today each CLI verb had its own ad-hoc "flag wins; else GEMBA_SERVER; else error" snippet (see the old resolveServer in internal/cli/bead_crud.go). That left no room for an on-disk default and made it impossible to operate against a remote server without typing --server every time.
Resolution precedence (highest to lowest):
- The --server flag (or any explicit per-call override).
- The GEMBA_SERVER environment variable.
- server.url in the user's config file: $XDG_CONFIG_HOME/gemba/config.toml (default ~/.config/gemba/config.toml).
- The compiled-in DefaultURL.
DefaultURL is "http://127.0.0.1:7666" — matches the default port the embedded `gemba serve` binds (internal/cli/serve.go). The bead spec originally proposed 7373 as a placeholder; that would not match a running gemba server and was rejected in implementation.
The credentials store (internal/auth/credstore) is a separate concern: it stores tokens keyed by server URL. The resolver runs first; its output is the credstore lookup key.
Index ¶
Constants ¶
const DefaultURL = "http://127.0.0.1:7666"
DefaultURL is the fallback server URL when nothing else is set.
This is intentionally the loopback default port for `gemba serve`. It matches the value baked into the serve command so a local dev workflow (one terminal `gemba serve`, another running `gemba bead list`) just works with no flags or env vars.
const EnvVar = "GEMBA_SERVER"
EnvVar is the environment variable name the resolver consults.
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
ConfigPath returns the absolute path to the gemba config.toml, honoring XDG_CONFIG_HOME. It does NOT check that the file exists.
Types ¶
type Config ¶
type Config struct {
Server ServerConfig `toml:"server"`
}
Config is the on-disk TOML shape. We only read [server].url today but the struct is intentionally a nested form so future knobs (e.g. [profile], [output]) can land without breaking existing files.
func LoadConfig ¶
LoadConfig reads the user's config.toml, returning an empty *Config (not nil) with nil error when the file is missing — a missing config file is normal, not an error. Returns an error only when the file exists but cannot be read or parsed.
type Result ¶
type Result struct {
URL string
Source Source
// File is the path of the loaded config.toml when Source is
// SourceFile; empty otherwise.
File string
}
Result is the verbose form Resolve produces internally. Most callers just want the URL string — use Resolve. Callers that need to know the source (config-show) use ResolveDetail.
func ResolveDetail ¶
ResolveDetail is Resolve plus where the URL came from. Used by `gemba config show`.
type ServerConfig ¶
type ServerConfig struct {
URL string `toml:"url"`
}
ServerConfig holds the [server] table.