Documentation
¶
Overview ¶
Package config loads and writes the fdb YAML config file (default location: ~/.fdb/config.yaml) using protoconfig. The file is structured as a `fdb.config.v1.Config` message — proto-backed so the schema is versioned and forwards-compatible.
Index ¶
- Variables
- func Load() (*configv1.Config, error)
- func LoadFrom(path string) (*configv1.Config, error)
- func Path() (string, error)
- func ResolveContext(cfg *configv1.Config, name string) (*configv1.Context, error)
- func Save(cfg *configv1.Config) error
- func SaveTo(path string, cfg *configv1.Config) error
- func SetCurrentContext(name string) error
- type ContextNotFoundError
Constants ¶
This section is empty.
Variables ¶
var ErrNoContext = errors.New("context not found")
ErrNoContext is returned by ResolveContext when the selected context does not exist in the loaded config.
Functions ¶
func LoadFrom ¶
LoadFrom reads the YAML file at path and returns the parsed Config. A missing file is not an error — protoconfig.Optional() makes the YAML source soft, so first-run commands (like `config use-context`) can operate on a zero value and then write back.
func Path ¶
Path returns the effective config path — FDB_CONFIG env var if set, else ~/.fdb/config.yaml.
func ResolveContext ¶
ResolveContext looks up a named context in the config. An empty name resolves Config.current_context. Returns ErrNoContext if the name is empty and no current context is set, or if the named context is absent.
func SaveTo ¶
SaveTo writes the Config to path as YAML, creating parent directories as needed. The existing file is atomically replaced via a temp file + rename, so a crash mid-write cannot leave a truncated config.
func SetCurrentContext ¶
SetCurrentContext rewrites ONLY the `current_context` scalar in the on-disk YAML, preserving every comment and all formatting. A Load→mutate→Save round-trip re-marshals through proto and destroys comments — including the guidance block `config init` just wrote — so the single-field update edits the YAML AST instead (RFC-174 Slice 5). A missing file degrades to a minimal document.
Types ¶
type ContextNotFoundError ¶
type ContextNotFoundError struct {
Name string
}
ContextNotFoundError identifies a selected context that is absent from the config.
func (*ContextNotFoundError) Error ¶
func (e *ContextNotFoundError) Error() string
func (*ContextNotFoundError) Unwrap ¶
func (e *ContextNotFoundError) Unwrap() error