Documentation
¶
Overview ¶
Package instance tracks the state of running klausctl container instances.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSuffix ¶ added in v0.0.34
AppendSuffix returns name + "-" + a random 4-char suffix.
func ContainerName ¶
ContainerName returns the container name for a given instance name.
func GenerateSuffix ¶ added in v0.0.34
GenerateSuffix returns a random 4-character lowercase hex string ([0-9a-f]) suitable for appending to instance names to avoid collisions.
Types ¶
type CollisionState ¶ added in v0.0.34
type CollisionState int
CollisionState describes the state of an existing instance that collides with a requested name.
const ( // NoCollision means no instance with the given name exists. NoCollision CollisionState = iota // CollisionStopped means an instance directory exists but no container is running. CollisionStopped // CollisionRunning means a container for this instance is currently running. CollisionRunning )
func CheckCollision ¶ added in v0.0.34
CheckCollision determines whether an instance with the given name already exists and, if so, whether its container is running or stopped.
type Instance ¶
type Instance struct {
// UUID uniquely identifies this instance run for archiving purposes.
UUID string `json:"uuid,omitempty"`
// Name is the instance name (default: "default").
Name string `json:"name"`
// ContainerID is the container ID returned by the runtime.
ContainerID string `json:"containerID"`
// Runtime is the container runtime used ("docker" or "podman").
Runtime string `json:"runtime"`
// Personality is the OCI reference of the resolved personality (empty when none).
Personality string `json:"personality,omitempty"`
// Image is the container image reference.
Image string `json:"image"`
// Port is the host port mapped to the MCP endpoint.
Port int `json:"port"`
// Workspace is the host workspace directory.
Workspace string `json:"workspace"`
// StartedAt is when the container was started.
StartedAt time.Time `json:"startedAt"`
}
Instance holds the state of a running klausctl container.
func LoadAll ¶ added in v0.0.11
LoadAll reads instance state files from all per-instance directories.
func (*Instance) ContainerName ¶
ContainerName returns the container name used by the runtime.