Add Go daemon-driven VM control plane

Replace the shell-only user workflow with `banger` and `bangerd`: Cobra commands, XDG/SQLite-backed state, managed VM and image lifecycle, and a Bubble Tea TUI for browsing and operating VMs.\n\nKeep Firecracker orchestration behind the daemon so VM specs become persistent objects, and add repo entrypoints for building, installing, and documenting the new flow while still delegating rootfs customization to the existing shell tooling.\n\nHarden the control plane around real usage by reclaiming Firecracker API sockets for the user, restarting stale daemons after rebuilds, and returning the correct `vm.create` payload so the CLI and TUI creation flow work reliably.\n\nValidation: `go test ./...`, `make build`, and a host-side smoke test with `./banger vm create --name codex-smoke`.
This commit is contained in:
Thales Maciel 2026-03-16 12:52:54 -03:00
parent 3cf33d1e0a
commit ea72ea26fe
No known key found for this signature in database
GPG key ID: 33112E6833C34679
22 changed files with 5480 additions and 0 deletions

81
internal/api/types.go Normal file
View file

@ -0,0 +1,81 @@
package api
import "banger/internal/model"
type Empty struct{}
type PingResult struct {
Status string `json:"status"`
PID int `json:"pid"`
}
type ShutdownResult struct {
Status string `json:"status"`
}
type VMCreateParams struct {
Name string `json:"name,omitempty"`
ImageName string `json:"image_name,omitempty"`
VCPUCount int `json:"vcpu_count,omitempty"`
MemoryMiB int `json:"memory_mib,omitempty"`
SystemOverlaySize string `json:"system_overlay_size,omitempty"`
WorkDiskSize string `json:"work_disk_size,omitempty"`
NATEnabled bool `json:"nat_enabled,omitempty"`
NoStart bool `json:"no_start,omitempty"`
}
type VMRefParams struct {
IDOrName string `json:"id_or_name"`
}
type VMSetParams struct {
IDOrName string `json:"id_or_name"`
VCPUCount *int `json:"vcpu_count,omitempty"`
MemoryMiB *int `json:"memory_mib,omitempty"`
WorkDiskSize string `json:"work_disk_size,omitempty"`
NATEnabled *bool `json:"nat_enabled,omitempty"`
}
type VMListResult struct {
VMs []model.VMRecord `json:"vms"`
}
type VMShowResult struct {
VM model.VMRecord `json:"vm"`
}
type VMStatsResult struct {
VM model.VMRecord `json:"vm"`
Stats model.VMStats `json:"stats"`
}
type VMLogsResult struct {
LogPath string `json:"log_path"`
}
type VMSSHResult struct {
Name string `json:"name"`
GuestIP string `json:"guest_ip"`
}
type ImageBuildParams struct {
Name string `json:"name,omitempty"`
BaseRootfs string `json:"base_rootfs,omitempty"`
Size string `json:"size,omitempty"`
KernelPath string `json:"kernel_path,omitempty"`
InitrdPath string `json:"initrd_path,omitempty"`
ModulesDir string `json:"modules_dir,omitempty"`
Docker bool `json:"docker,omitempty"`
}
type ImageRefParams struct {
IDOrName string `json:"id_or_name"`
}
type ImageListResult struct {
Images []model.Image `json:"images"`
}
type ImageShowResult struct {
Image model.Image `json:"image"`
}