import "go.sbk.wtf/runj/state"
Dir returns the state directory for a container
Remove removes the state for a container
SetDir overrides the state directory and returns a function that restores the previous value. It is intended for tests that need an isolated, writable state directory.
type Output struct {
OCIVersion string `json:"ociVersion"`
ID string `json:"id"`
Status string `json:"status"`
PID int `json:"pid,omitempty"`
Bundle string `json:"bundle"`
Annotations map[string]string `json:"annotations,omitempty"`
}
Output is the expected output format for the state command
{
"ociVersion": "0.2.0",
"id": "oci-container1",
"status": "running",
"pid": 4422,
"bundle": "/containers/redis",
"annotations": {
"myKey": "myValue"
}
}
type State struct {
// ID is the ID of the container
ID string
// JID is the jail ID of the jail backing the container
JID int
// Status is the status of the container
Status Status
// Bundle is the directory containing the config and rootfs
Bundle string
// PID is the primary process ID
PID int
// OCIVersion is the OCI runtime spec version the bundle declared
OCIVersion string
}
State represents the state of a container
Create creates a state file for runj
Load reads the state from disk and parses it
Output converts the state to the "Output" format expected by hooks
Save saves the state to disk
Status is the type for representing container status
const ( // StatusCreating represents a container in the process of being created StatusCreating Status = "creating" // StatusCreated represents a container that has been created but not started StatusCreated Status = "created" // StatusRunning represents a running container StatusRunning Status = "running" // StatusStopped represents a container that has exited StatusStopped Status = "stopped" )