Skip to content

SuperInstance/fleet-config

Repository files navigation

Fleet Config Manager

Unified configuration management for the Pelagic fleet. Bridges the fragmented config landscape — fleet.yaml, per-agent agent.yaml, world/rooms.json, lighthouse config, environment variables, and runtime overrides — into one coherent system.

Features

  • Layered config priority — CLI args > env vars > runtime overrides > fleet.yaml > agent.yaml > defaults
  • Schema validation — type checking, required fields, port conflict detection, path existence
  • Config templates — development, production, minimal, full, and Docker presets
  • Template rendering{{keeper.port}} placeholders resolved from config context
  • Secret redaction — sensitive fields are masked in diffs and exports
  • Config snapshots — save/rollback config states for safe experimentation
  • Multi-format export — YAML, JSON, and ENV-file output
  • Doctor diagnostics — detect misconfigurations, port conflicts, missing files

Quick Start

# Generate a config from a template
python cli.py generate --template development

# View current config
python cli.py show

# Get a value
python cli.py get keeper.port

# Set a value
python cli.py set keeper.port 9000

# Validate
python cli.py validate

# Diff from defaults
python cli.py diff

# Save a snapshot before making changes
python cli.py snapshot --label "pre-migration"

# Rollback if something breaks
python cli.py rollback pre-migration

# Export as JSON (secrets redacted)
python cli.py export --format json

# Diagnose issues
python cli.py doctor

Config Priority (highest → lowest)

Priority Source Example
1 CLI arguments --port 9000
2 Environment variables FLEET_KEEPER_PORT=9000
3 Runtime overrides manager.set("keeper.port", 9000)
4 Fleet config fleet.yaml
5 Agent config <agent>/agent.yaml
6 Defaults Built-in template defaults

Programmatic Usage

from config_manager import FleetConfigManager

manager = FleetConfigManager(config_dir="/etc/fleet")

# Load config (auto-applies all layers)
config = manager.load_fleet_config()

# Get/set values
port = manager.get("keeper.port")
manager.set("logging.level", "DEBUG")

# Validate
result = manager.validate()
if not result.valid:
    print(result)

# Generate agent-specific config
agent_cfg = manager.generate_agent_config("git-agent")

# Save snapshot before changes
manager.snapshot(label="before-update")

Templates

Template Description
development Local dev — all on localhost, debug logging
production Production — separate hosts, TLS, JSON logs
minimal Minimal — Keeper + Git Agent only
full Full — all agents enabled
docker Docker — internal container networking

Architecture

fleet-config/
├── config_manager.py   # Core: FleetConfigManager class
├── schema.py           # JSON Schema-like validation
├── templates.py        # Pre-built config templates
├── cli.py              # CLI subcommands
├── tests/
│   └── test_fleet_config.py  # Unit tests
├── pyproject.toml
└── README.md

Running Tests

cd fleet/fleet-config
python -m pytest tests/ -v

Dependencies

  • Python >= 3.11
  • PyYAML >= 6.0 (only external dependency)
  • stdlib: json, os, re, copy, argparse, unittest, tempfile, shutil, datetime, pathlib

About

Unified configuration management for Pelagic fleet — schema validation, templates, snapshots

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages