config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 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 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.

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

	// 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.

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).

Jump to

Keyboard shortcuts

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