serverconfig

package
v0.0.0-...-13f862e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 6 Imported by: 0

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):

  1. The --server flag (or any explicit per-call override).
  2. The GEMBA_SERVER environment variable.
  3. server.url in the user's config file: $XDG_CONFIG_HOME/gemba/config.toml (default ~/.config/gemba/config.toml).
  4. 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

View Source
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.

View Source
const EnvVar = "GEMBA_SERVER"

EnvVar is the environment variable name the resolver consults.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the absolute path to the gemba config.toml, honoring XDG_CONFIG_HOME. It does NOT check that the file exists.

func Resolve

func Resolve(flag string) (string, error)

Resolve returns the resolved server URL, following the documented precedence. A whitespace-only flag value counts as unset.

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

func LoadConfig() (*Config, error)

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

func ResolveDetail(flag string) (Result, error)

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.

type Source

type Source string

Source describes where a resolved URL came from. The CLI prints this via `gemba config show` so operators can see why a verb hit a given server.

const (
	SourceFlag    Source = "flag"
	SourceEnv     Source = "env"
	SourceFile    Source = "file"
	SourceDefault Source = "default"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL