Documentation
¶
Overview ¶
Package setup holds the onboarding and configuration services: the documents the local API returns and the pure reads that build the same documents from state files when no server is running. Presentations (CLI, TUI, web) render these documents; they never compute next actions, order or validation themselves.
See decision 0006 and spec/features/configuration-parity#REQ:json-equals-api.
Index ¶
- Constants
- func FallbackAddress(port int) string
- func ParsePort(value, source string) (int, *envelope.Error)
- func PrimaryAddress(port int) string
- func ResolvePort(flagPort int, getenv paths.Getenv, config Config) (port int, explicit bool, err *envelope.Error)
- func UnknownConfigKey(key string) *envelope.Error
- type Config
- type ConfigChange
- type ConfigDocument
- type Server
- type ServerConfig
- type ServerDocument
- type Status
Constants ¶
const ( StateRunning = "running" StateNotRunning = "not_running" StateStopping = "stopping" // only in the shutdown response )
Server states.
const ConfigFile = "config.yaml"
ConfigFile is the configuration file in OVDB home.
const EnvPort = "OVDB_PORT"
EnvPort overrides the configured port for one shell.
const KeyServerPort = "server.port"
KeyServerPort is the only configuration key increment 1a implements; server.cors, telemetry and the global context follow in later increments.
Variables ¶
This section is empty.
Functions ¶
func FallbackAddress ¶
FallbackAddress is the address that works where *.localhost does not.
func ParsePort ¶
ParsePort validates a port number given through source (a flag, variable or key name).
func PrimaryAddress ¶
PrimaryAddress is the address people open.
func ResolvePort ¶
func ResolvePort(flagPort int, getenv paths.Getenv, config Config) (port int, explicit bool, err *envelope.Error)
ResolvePort applies --port > OVDB_PORT > server.port > 6832 (REQ:port-precedence). explicit is true for the flag and the variable, which must match a running server's port.
func UnknownConfigKey ¶
UnknownConfigKey is invalid_argument naming the supported keys.
Types ¶
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server,omitempty" json:"server"`
}
Config is config.yaml. Unset values are omitted and mean "default".
func LoadConfig ¶
LoadConfig reads config.yaml; a missing file is the empty configuration.
type ConfigChange ¶
ConfigChange is the body of PUT /api/local/v1/config.
type ConfigDocument ¶
type ConfigDocument struct {
Schema int `json:"schema"`
Config Config `json:"config"`
Next []envelope.Next `json:"next"`
}
ConfigDocument is the body of GET/PUT /api/local/v1/config and the --json output of `ovdb config get|set`.
func ApplyConfigChange ¶
func ApplyConfigChange(dirs paths.Dirs, change ConfigChange, serverRunning bool) (ConfigDocument, error)
ApplyConfigChange validates change, writes config.yaml owner-only and returns the resulting document. The caller must be the home's single writer: the running server, or a client holding home.lock (serverRunning false).
func NewConfigDocument ¶
func NewConfigDocument(config Config, changedWhileRunning bool) ConfigDocument
NewConfigDocument wraps config. A change made while the server runs gets the restart that applies it as its next action.
type Server ¶
type Server struct {
State string `json:"state"`
Address string `json:"address"`
FallbackAddress string `json:"fallback_address"`
Port int `json:"port"`
Version string `json:"version,omitempty"`
PID int `json:"pid,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
Log string `json:"log"`
}
Server describes the local OVDB server in status and server documents. It carries no uptime: a start time keeps two reads of the same server byte-identical, and presentations format the uptime from it.
func RunningServer ¶
RunningServer describes the server recorded in record.
type ServerConfig ¶
type ServerConfig struct {
Port int `yaml:"port,omitempty" json:"port,omitempty"`
}
ServerConfig is the server section of config.yaml.
type ServerDocument ¶
ServerDocument is the body of GET /api/local/v1/server and the --json output of `ovdb server start|stop|restart|status`.
func NewServerDocument ¶
func NewServerDocument(server Server) ServerDocument
NewServerDocument wraps server in its document.
type Status ¶
type Status struct {
Schema int `json:"schema"`
Version string `json:"version"`
Locations paths.Dirs `json:"locations"`
Server Server `json:"server"`
Next []envelope.Next `json:"next"`
}
Status is the body of GET /api/local/v1/status and of `ovdb status --json` (first-run-onboarding#REQ:status-command). Later increments add databases, context, demo, skills and telemetry as they are implemented.