machines

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package machines models the inventory of remote machines.

A Machine is the testfleet-internal view of a remote host: the union of what Tailscale tells us (name, OS, tags, last-seen) and what local inventory overrides supply (remote_prefix, snapshot_caps). The JSON shape is part of the --json public contract — bump output.SchemaVersion if you change it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBusy

func ApplyBusy(ms []Machine, isBusy func(name string) bool)

ApplyBusy overrides idle→busy in place when isBusy(name) reports true.

Only StatusIdle machines are promoted: an offline machine (one we can't reach) can't be meaningfully "busy", and unknown/already-busy states are left as-is. The predicate is supplied by the caller (typically a runs-store ActiveByMachine lookup) so this package needs no dependency on runs — keeping the busy projection free of an import cycle.

func DefaultInventoryPath

func DefaultInventoryPath() (string, error)

DefaultInventoryPath returns ~/.testfleet/inventory.yaml.

Types

type HostOverride

type HostOverride struct {
	RemotePrefix string `yaml:"remote_prefix"`
	SnapshotCaps string `yaml:"snapshot_caps"`
}

HostOverride mirrors tailscale.HostOverride but lives here so cmd/ packages can load inventory without importing tailscale.

type Inventory

type Inventory struct {
	Hosts map[string]HostOverride `yaml:"hosts"`
}

Inventory is the parsed ~/.testfleet/inventory.yaml structure.

Schema (intentionally tiny for MVP):

hosts:
  win-5060ti:
    remote_prefix: "C:\\testfleet"
    snapshot_caps: "vss"

func LoadInventory

func LoadInventory(path string) (Inventory, error)

LoadInventory reads and parses path. A missing file is not an error — it returns an empty Inventory so callers can call this unconditionally.

type Machine

type Machine struct {
	Name         string    `json:"name"`
	Host         string    `json:"host,omitempty"` // FQDN / IP used for SSH dial; empty = fall back to Name
	OS           string    `json:"os"`
	Tags         []string  `json:"tags"`
	Status       Status    `json:"status"`
	SnapshotCaps string    `json:"snapshot_caps"`
	RemotePrefix string    `json:"remote_prefix"`
	LastSeen     time.Time `json:"last_seen"`
}

Machine is the unified view of a remote host.

JSON tags use snake_case to match the rest of the testfleet wire format. LastSeen serializes as RFC3339; the zero value marshals as "0001-01-01T00:00:00Z".

type Status

type Status string

Status is the runtime state of a machine, derived from Tailscale lastSeen plus (future) busy detection from the runs store.

const (
	StatusIdle    Status = "idle"
	StatusBusy    Status = "busy"
	StatusOffline Status = "offline"
	StatusUnknown Status = "unknown"
)

Jump to

Keyboard shortcuts

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