config

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config loads fort-core configuration from the environment with sane defaults (backlog AO-011).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadOrCreateCapabilityKey added in v0.13.0

func LoadOrCreateCapabilityKey(dir string) ([]byte, error)

LoadOrCreateCapabilityKey returns the node-local key used to derive opaque capability binding revisions. The raw key never leaves the execution plane.

func SaveNodeFile added in v0.6.0

func SaveNodeFile(dir string, nf NodeFile) error

SaveNodeFile writes dir/node.yaml atomically with mode 0600 throughout — the temp file is created 0600 before any bytes are written, so the token is never world-readable, even transiently.

func SaveRelay added in v0.10.0

func SaveRelay(dir string, rc RelayConfig) error

SaveRelay writes dir/relay.yaml atomically with mode 0600 throughout — the temp file is created 0600 before any bytes are written, so the device token and private key are never world-readable, even transiently. Mirrors SaveNodeFile.

Types

type Config

type Config struct {
	Addr      string // HTTP/WS bind address
	DBPath    string // SQLite state-store path
	RulesPath string // active routing ruleset
	WorkRoot  string // scoped root all native runtimes execute under
	// DisplayTimezone is the optional IANA timezone shared by every Today
	// client. Empty resolves from the daemon host at startup.
	DisplayTimezone string

	// Multi-machine orchestration (spec 022). All optional: with MachinesPath
	// empty, Fort is single-machine and behaves exactly as before.
	NodeName     string // this machine's identity in the registry (default: hostname)
	MachinesPath string // path to machines.yaml ("" = single-machine)
	NodeToken    string // shared bearer token for inter-Fort /api/exec calls

	// MachinesManaged is true when MachinesPath points at the Fort-managed
	// registry in the data dir (spec 024). Enrollment only ever writes the
	// managed file; an operator-set FORT_MACHINES is never touched.
	MachinesManaged bool
}

Config is the fort-core runtime configuration.

func Default

func Default() Config

Default returns the built-in configuration.

func FromEnv

func FromEnv(getenv func(string) string) Config

FromEnv layers FORT_* environment overrides over the defaults. getenv is injectable for testing (pass os.Getenv in production).

func Load added in v0.6.0

func Load(getenv func(string) string) Config

Load is FromEnv plus the spec-024 layers, precedence env > node.yaml > defaults for NodeToken / NodeName / Addr, and managed-registry discovery: FORT_MACHINES env > <data-dir>/machines.yaml exists > single-machine.

func (Config) DataDir added in v0.6.0

func (c Config) DataDir() string

DataDir is where Fort keeps machine-local state (node.yaml, the managed machines.yaml): the directory holding the SQLite DB.

func (Config) DisplayLocation added in v1.0.4

func (c Config) DisplayLocation() (*time.Location, error)

DisplayLocation resolves the one IANA timezone used by every Today client. An explicit FORT_DISPLAY_TIMEZONE is authoritative; otherwise Fort derives the host's zone from TZ or the standard /etc/localtime link.

type NodeFile added in v0.6.0

type NodeFile struct {
	Name  string `yaml:"name"`
	Token string `yaml:"token"`
	Addr  string `yaml:"addr"`
}

NodeFile is the persisted mesh identity of one machine (spec 024): written by `fort mesh join` on workers and by the first `fort mesh invite` on the hub. It contains the shared mesh token, so it is always written 0600.

func ReadNodeFile added in v0.6.0

func ReadNodeFile(dir string) (NodeFile, error)

ReadNodeFile loads dir/node.yaml. A missing file is not an error — it returns the zero NodeFile (nothing enrolled yet).

type RelayConfig added in v0.10.0

type RelayConfig struct {
	GatewayURL  string
	DeviceToken string
	MachineID   string
	PrivateKey  []byte
	PublicKey   []byte
}

RelayConfig is the persisted remote-gateway identity of one machine (spec 028): written by `fort relay join`. It holds the device token and this machine's static Noise keypair, so relay.yaml is always written 0600.

func LoadRelay added in v0.10.0

func LoadRelay(dir string) (RelayConfig, error)

LoadRelay reads dir/relay.yaml. Unlike ReadNodeFile, a missing file is NOT swallowed: the os.IsNotExist-compatible error is returned so callers can use `if _, err := LoadRelay(dir); err == nil` to decide whether a relay is configured.

Jump to

Keyboard shortcuts

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