fleet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fleet declares, in code, which Proxmox container runs which service, so a push deploy job can prove it is touching the right container and a nightly check can catch the fleet drifting away from the code.

A Fleet synthesizes to .yawn/fleet.json (data only, no secrets). The deploy job on the Proxmox host reads that file at a verified commit; Discover and Diff compare it with what `pct` reports.

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion of fleet.json.

Variables

This section is empty.

Functions

func Blocking

func Blocking(findings []Finding) bool

Blocking reports whether any finding refuses a deploy.

func ParsePctList

func ParsePctList(out string) (map[int]string, error)

ParsePctList reads `pct list` output into CTID -> status.

func ParseUpdateEntrypoint

func ParseUpdateEntrypoint(content string) string

ParseUpdateEntrypoint extracts the community-scripts slug from a container's /usr/bin/update: SCRIPT_SLUG in current entrypoints, otherwise the ct/<name>.sh an older entrypoint downloads. Unsafe values return "".

Types

type Container

type Container struct {
	// Node is the Proxmox node name, e.g. "kratos".
	Node string `json:"node"`
	// CTID is the Proxmox container ID.
	CTID int `json:"ctid"`
	// Hostname must match the container's configured hostname.
	Hostname string `json:"hostname"`
	// IP is the container's IPv4 address; the deploy job checks the running
	// container really holds it.
	IP string `json:"ip"`
	// Unprivileged containers are expected; privileged ones must say so.
	Privileged bool `json:"privileged,omitempty"`
}

Container is a Proxmox LXC as it must look before any deploy touches it.

type Document

type Document struct {
	Version  int        `json:"fleet_version"`
	Services []*Service `json:"services"`
}

Document is the fleet.json schema.

type Finding

type Finding struct {
	Severity Severity `json:"severity"`
	Service  string   `json:"service,omitempty"`
	CTID     int      `json:"ctid,omitempty"`
	Message  string   `json:"message"`
}

Finding is one difference between code and the live fleet.

func Check

func Check(s *Service, o Observed) []Finding

Check proves one observed container is the declared service. The deploy job calls it immediately before touching the container; any Block finding means "refuse".

func Diff

func Diff(f *Fleet, observed []Observed) []Finding

Diff compares the declared fleet with observed containers on the given nodes. Every declared service must exist exactly as declared; observed containers that no service claims are reported so the code cannot go stale.

type Fleet

type Fleet struct {
	// contains filtered or unexported fields
}

Fleet is the declared set of services.

func Load

func Load(data []byte) (*Fleet, error)

Load parses fleet.json, refusing unknown fields and other schema versions, and re-validates every entry exactly as Add does.

func New

func New() *Fleet

New returns an empty fleet.

func (*Fleet) Add

func (f *Fleet) Add(s Service) *Service

Add declares a service. It panics on invalid input or a duplicate ID, CTID, IP or route, like the other cdk constructs.

func (*Fleet) JSON

func (f *Fleet) JSON() ([]byte, error)

JSON renders fleet.json deterministically.

func (*Fleet) Lookup

func (f *Fleet) Lookup(id string) (*Service, bool)

Lookup returns a service by ID.

func (*Fleet) Services

func (f *Fleet) Services() []*Service

Services returns the services sorted by ID.

type Kind

type Kind string

Kind is how a service is installed, which decides how it is updated.

const (
	// CommunityScript was installed by a community-scripts.org script; it
	// updates through the /usr/bin/update entrypoint the script wrote.
	CommunityScript Kind = "community-script"
	// Compose runs as Docker Compose inside the container.
	Compose Kind = "compose"
	// Custom has a bespoke, reviewed deploy script (e.g. the Caddy edge).
	Custom Kind = "custom"
	// Unmanaged is recorded for identity and drift only; deploys refuse it.
	Unmanaged Kind = "unmanaged"
)

type Observed

type Observed struct {
	Node     string `json:"node"`
	CTID     int    `json:"ctid"`
	Hostname string `json:"hostname"`
	IP       string `json:"ip"`
	// DHCP is true when net0 uses ip=dhcp; IP is then the live address.
	DHCP bool `json:"dhcp,omitempty"`
	// MAC is net0 hwaddr (lowercase), for DHCP reservations.
	MAC          string   `json:"mac,omitempty"`
	Status       string   `json:"status"`
	Unprivileged bool     `json:"unprivileged"`
	Tags         []string `json:"tags,omitempty"`
	// Script is the community-scripts slug from /usr/bin/update (SCRIPT_SLUG,
	// or the ct/<name>.sh an older entrypoint references), empty if absent.
	Script string `json:"script,omitempty"`
	// BindMounts counts mpN entries with a host path (data a pct snapshot
	// would not cover). Paths themselves are not recorded.
	BindMounts int `json:"bind_mounts"`
}

Observed is what the Proxmox host reports about one container. Discovery fills it from `pct list`, `pct config <id>` and the container's /usr/bin/update; it never contains secrets or environment values.

func ParsePctConfig

func ParsePctConfig(node string, ctid int, status, config string) (Observed, error)

ParsePctConfig reads the output of `pct config <ctid>` (current section only; snapshot sections in [brackets] are ignored). Only the fields fleet needs are kept, so descriptions or other free text never leave the host.

type Service

type Service struct {
	ID        string    `json:"id"`
	Container Container `json:"container"`
	Kind      Kind      `json:"kind"`
	// Script is the community-scripts slug recorded in the container's
	// /usr/bin/update (SCRIPT_SLUG), e.g. "immich". Required for CommunityScript.
	Script string `json:"script,omitempty"`
	// Routes are the edge hostnames served by this container (from john/ops
	// edge/routes.json), e.g. ["photos"].
	Routes []string `json:"routes,omitempty"`
	// Health is an HTTP(S) URL that must answer 2xx/3xx after a deploy.
	Health string `json:"health,omitempty"`
	// Secrets are the xyOps secret IDs granted to this service's deploy event.
	Secrets []string `json:"secrets,omitempty"`
	// Snapshot before each deploy so a failed health check rolls back.
	// Defaults to true; containers with bind mounts may need false (pct
	// snapshots do not cover bind-mounted data).
	NoSnapshot bool   `json:"no_snapshot,omitempty"`
	Notes      string `json:"notes,omitempty"`
}

Service is one application and how to reach, identify and update it.

type Severity

type Severity string

Severity of a finding.

const (
	// Block means a deploy to this service must refuse.
	Block Severity = "block"
	// Warn is drift worth a notification but not a refusal.
	Warn Severity = "warn"
)

Jump to

Keyboard shortcuts

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