Documentation
¶
Overview ¶
Package settings is the typed runtime-settings registry: a code-defined catalog of keys with kinds, defaults, and validators, backed by the `settings` table. Boot-level configuration lives in TOML (internal/config); everything an administrator may change while the node runs lives here. Values the docs mark as "recommended defaults" (MTU, ports, DNS, interface cap) are ordinary registry entries an administrator can override.
Index ¶
- func ValidEndpoint(s string) error
- func ValidSubnet(s string) error
- func ValidateStoredValue(def Definition, stored string) error
- type Definition
- type Item
- type Kind
- type Registry
- func (r *Registry) All(ctx context.Context) ([]Item, error)
- func (r *Registry) Definitions() []Definition
- func (r *Registry) Get(ctx context.Context, key string) (any, error)
- func (r *Registry) GetBool(ctx context.Context, key string) (bool, error)
- func (r *Registry) GetInt(ctx context.Context, key string) (int, error)
- func (r *Registry) GetSecret(ctx context.Context, key string) (string, error)
- func (r *Registry) GetString(ctx context.Context, key string) (string, error)
- func (r *Registry) GetStringList(ctx context.Context, key string) ([]string, error)
- func (r *Registry) Reset(ctx context.Context, key string) error
- func (r *Registry) Set(ctx context.Context, key string, value any) error
- func (r *Registry) SetBatch(ctx context.Context, updates []Update) error
- func (r *Registry) SetRaw(ctx context.Context, key, raw string) error
- func (r *Registry) Validate(key string, value any) error
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidEndpoint ¶
ValidEndpoint validates the host or host:port form written to client configuration Endpoint lines. URLs, paths, control characters, whitespace, invalid bracket notation, and ports outside 1..65535 are rejected. Bare IPv6 addresses are accepted and bracketed by the client-config renderer.
func ValidSubnet ¶
ValidSubnet is shared validation used by the interface service and tests for pool-shaped strings.
func ValidateStoredValue ¶ added in v0.1.9
func ValidateStoredValue(def Definition, stored string) error
ValidateStoredValue uses the current setting contract without opening a node or changing its cache. Secret values must already be decrypted by the caller.
Types ¶
type Definition ¶
type Definition struct {
Key string
Kind Kind
Default any
Min, Max int64
Options []string
Validator func(v any) error
Category string // general|networking|accounting|security|backup|drift|interfaces
Secret bool
Advanced bool // hidden behind the Settings UI "advanced" gate
Persistent bool // change requires the owning feature to re-render state
}
Definition is one registry entry. Min/Max apply to KindInt; Options restrict KindString to an enum; Validator adds cross-field or structural rules on the typed value.
func Defaults ¶
func Defaults() []Definition
Defaults is the Phase 1 catalog. Every value here is a *recommended default* chosen from upstream constraints (docs/operations/deployment.md) — administrators may change any of it; final guidance follows the Phase 11 production matrix. Phases add keys; keys are never renamed (Settings/API contract).
type Item ¶
type Item struct {
Definition
Value any
IsZero bool // value equals the default (row absent)
Updated time.Time
}
Item is a resolved setting returned to UIs/CLI.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is safe for concurrent use. Values are cached in memory and invalidated on write; this is a read-heavy, write-rare table.
func (*Registry) All ¶
All resolves every definition (settings screens). Secret values are redacted to "<set>"/"" — never returned in plaintext.
func (*Registry) Definitions ¶
func (r *Registry) Definitions() []Definition
Definitions returns the catalog (order undefined).
func (*Registry) GetSecret ¶
GetSecret returns the decrypted secret value ("" when unset). It is the only accessor that yields plaintext; the value must never be logged.
func (*Registry) GetString ¶
Typed getters. A wrong-kind expectation is a programmer error surfaced as an error, not a panic.
func (*Registry) GetStringList ¶
func (*Registry) SetBatch ¶
SetBatch validates and encodes every update before writing any of them, then commits the complete set in one SQLite transaction. Failed validation, encryption, writes, and commits leave both persisted state and cache intact.
func (*Registry) SetRaw ¶
SetRaw validates and stores a textual input (CLI/API form); parsing is kind-driven. Secret values are plaintext on input, encrypted at rest.