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
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
// 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 FromEnv ¶
FromEnv layers FORT_* environment overrides over the defaults. getenv is injectable for testing (pass os.Getenv in production).
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
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.