setup

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

View Source
const (
	StateRunning    = "running"
	StateNotRunning = "not_running"
	StateStopping   = "stopping" // only in the shutdown response
)

Server states.

View Source
const ConfigFile = "config.yaml"

ConfigFile is the configuration file in OVDB home.

View Source
const EnvPort = "OVDB_PORT"

EnvPort overrides the configured port for one shell.

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

func FallbackAddress(port int) string

FallbackAddress is the address that works where *.localhost does not.

func ParsePort

func ParsePort(value, source string) (int, *envelope.Error)

ParsePort validates a port number given through source (a flag, variable or key name).

func PrimaryAddress

func PrimaryAddress(port int) string

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

func UnknownConfigKey(key string) *envelope.Error

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

func LoadConfig(home string) (Config, error)

LoadConfig reads config.yaml; a missing file is the empty configuration.

type ConfigChange

type ConfigChange struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

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

func RunningServer(record *runtime.Record, dirs paths.Dirs) Server

RunningServer describes the server recorded in record.

func StoppedServer

func StoppedServer(port int, dirs paths.Dirs) Server

StoppedServer describes a server that is not running and would start on port.

type ServerConfig

type ServerConfig struct {
	Port int `yaml:"port,omitempty" json:"port,omitempty"`
}

ServerConfig is the server section of config.yaml.

type ServerDocument

type ServerDocument struct {
	Schema int    `json:"schema"`
	Server Server `json:"server"`
}

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.

func NewStatus

func NewStatus(version string, dirs paths.Dirs, server Server) Status

NewStatus builds the status for this ovdb version, locations and server. next lists only implemented options, in the founder's order.

Jump to

Keyboard shortcuts

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