Documentation
¶
Overview ¶
Package protocol is the loomux-plugin/1 protocol's vocabulary: the method names the host calls and the parameter and result types they carry (docs/design/target-providers.md §1.3). It imports nothing of Loomux, so the host, the SDK and any plugin share it without cycles.
Index ¶
- Constants
- Variables
- func RequiredCapability(method string) string
- func ValidTmuxSocket(name string) bool
- type Address
- type AttachCommand
- type AttachParams
- type AttachResult
- type CheckResult
- type ConfigureParams
- type Environment
- type EnvironmentHealth
- type EnvironmentSpec
- type HostInfo
- type IDParams
- type ListResult
- type Problem
- type RecreateParams
- type SSHBootstrap
- type Size
- type TargetsChanged
- type TargetsInfo
Constants ¶
const ( // MethodDescribe returns the plugin's manifest: the handshake. MethodDescribe = "plugin.describe" // MethodConfigure hands the plugin its configuration and what it // needs to know about the host (ConfigureParams). MethodConfigure = "plugin.configure" // MethodCheck asks the plugin to verify its credentials and // reachability (CheckResult). MethodCheck = "plugin.check" // MethodShutdown asks it to stop cleanly. MethodShutdown = "plugin.shutdown" )
Methods of the plugin.* group, which every plugin serves.
const ( SeverityWarning = "warning" SeverityError = "error" )
Problem severities.
const ( MethodTargetsDescribe = "targets.describe" MethodTargetsCreate = "targets.create" MethodTargetsGet = "targets.get" MethodTargetsList = "targets.list" MethodTargetsStart = "targets.start" MethodTargetsStop = "targets.stop" MethodTargetsRecreate = "targets.recreate" MethodTargetsDestroy = "targets.destroy" MethodTargetsHealth = "targets.health" MethodTargetsAttachCommands = "targets.attach_commands" )
The targets.* group: a target provider makes machines on demand (docs/design/target-providers.md §1.3, §1.9). The host calls these only on a plugin whose manifest declares targets.create.
const ( CapTargetsCreate = "targets.create" CapTargetsStopStart = "targets.stop_start" CapTargetsRecreate = "targets.recreate" CapTargetsPersistent = "targets.persistent" CapTargetsEphemeral = "targets.ephemeral" CapTargetsEgressPolicy = "targets.egress_policy" CapTargetsAttachCommands = "targets.attach_commands" )
Capabilities of the targets group, as a manifest declares them.
const ( EnvCreating = "creating" EnvStarting = "starting" EnvRunning = "running" EnvStopped = "stopped" EnvRecreating = "recreating" EnvDestroying = "destroying" EnvLost = "lost" EnvError = "error" )
Environment statuses (Environment.Status).
const ( LabelInstance = "loomux.io/instance" LabelTarget = "loomux.io/target" LabelEnvironment = "loomux.io/environment" )
Labels the host puts on every spec, and a plugin on every object it makes, so it only ever touches its own.
const ( EgressInternet = "internet" EgressNone = "none" )
Egress values.
const ( SSHProxyNone = "none" SSHProxyDefault = "default" )
SSH proxy values (TargetsInfo.SSHProxy, Address.Proxy): how the host reaches the machines, as a target's ssh_proxy.
const DefaultTmuxSocket = "loomux"
DefaultTmuxSocket is the socket an AttachParams without one names: the host's own default (targets.DefaultTmuxSocket).
const NotifyTargetsChanged = "targets.changed"
NotifyTargetsChanged is the one notification a plugin may send the host: a hint that a machine's status changed, never the truth. Part of loomux-plugin/1 from the start, so it needs no version or capability: a peer that doesn't handle a notification ignores it (no id, so no answer), and a plugin that never sends it leaves the host to its periodic reconcile (LOOM-213).
const Version = "loomux-plugin/1"
Version is the protocol this package describes.
Variables ¶
var EnvironmentStatuses = []string{EnvCreating, EnvStarting, EnvRunning, EnvStopped, EnvRecreating, EnvDestroying, EnvLost, EnvError}
EnvironmentStatuses is every status a plugin may report.
Functions ¶
func RequiredCapability ¶ added in v0.3.69
RequiredCapability is the capability a manifest must declare for the host to call method; "" for a method outside the targets group.
func ValidTmuxSocket ¶ added in v0.3.103
ValidTmuxSocket reports whether name can be a socket name, the grammar targets.ValidTmuxSocket enforces on the host: it goes into the shell commands a plugin returns, unquoted.
Types ¶
type Address ¶ added in v0.3.69
type Address struct {
Host string `json:"host"`
Port int `json:"port"`
Proxy string `json:"proxy"`
}
Address is how the host reaches a machine's sshd.
type AttachCommand ¶ added in v0.3.69
AttachCommand is one way a person attaches to a machine's tmux.
type AttachParams ¶ added in v0.3.69
type AttachParams struct {
ID string `json:"id"`
Session string `json:"session"`
Socket string `json:"socket,omitempty"`
}
AttachParams are targets.attach_commands'. Socket is the tmux socket the host runs the machine's sessions on, its instance's (LOOM-210): the commands must attach to that one. A host from before LOOM-210 sends none, which means DefaultTmuxSocket.
type AttachResult ¶ added in v0.3.69
type AttachResult struct {
Commands []AttachCommand `json:"commands"`
}
AttachResult is targets.attach_commands' result.
type CheckResult ¶
CheckResult is plugin.check's result. OK is false when any problem has severity error.
type ConfigureParams ¶
type ConfigureParams struct {
// Config is the configuration as the manifest's schema describes it,
// secret fields included: the channel is private to the two
// processes.
Config map[string]any `json:"config"`
Host HostInfo `json:"host"`
}
ConfigureParams are plugin.configure's parameters.
type Environment ¶ added in v0.3.69
type Environment struct {
ID string `json:"id"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Address Address `json:"address"`
ImageDigest string `json:"image_digest,omitempty"`
Size string `json:"size"`
Persistent bool `json:"persistent"`
Egress string `json:"egress"`
CreatedAt time.Time `json:"created_at"`
}
Environment is a machine as the plugin sees it.
type EnvironmentHealth ¶ added in v0.3.69
type EnvironmentHealth struct {
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Restarts int `json:"restarts"`
ImageDigest string `json:"image_digest,omitempty"`
}
EnvironmentHealth is targets.health's result: the plugin's own view.
type EnvironmentSpec ¶ added in v0.3.69
type EnvironmentSpec struct {
ID string `json:"id"`
TargetID string `json:"target_id"`
Name string `json:"name"`
Size string `json:"size"`
Persistent bool `json:"persistent"`
Egress string `json:"egress"`
Image string `json:"image"`
SSH SSHBootstrap `json:"ssh"`
Labels map[string]string `json:"labels"`
}
EnvironmentSpec is targets.create's parameter: everything a plugin needs for one machine, and nothing else.
type HostInfo ¶
type HostInfo struct {
// Version is the host's version string.
Version string `json:"version"`
// InstanceID labels everything the plugin makes as this server's.
InstanceID string `json:"instance_id"`
// DataDir is a directory of the plugin's own on the host's data
// volume, for a subprocess that needs to keep state.
DataDir string `json:"data_dir,omitempty"`
}
HostInfo is what a plugin learns about the host at configure.
type IDParams ¶ added in v0.3.69
type IDParams struct {
ID string `json:"id"`
}
Parameters of the id-taking methods.
type ListResult ¶ added in v0.3.69
type ListResult struct {
Environments []Environment `json:"environments"`
}
ListResult is targets.list's result.
type Problem ¶
type Problem struct {
// Code is stable and machine-readable ("network_policy_not_enforced");
// Message is for a person.
Code string `json:"code"`
Message string `json:"message"`
Severity string `json:"severity"`
}
Problem is one thing plugin.check found.
type RecreateParams ¶ added in v0.3.69
type RecreateParams struct {
ID string `json:"id"`
Spec EnvironmentSpec `json:"spec"`
}
RecreateParams are targets.recreate's.
type SSHBootstrap ¶ added in v0.3.69
type SSHBootstrap struct {
AuthorizedKey string `json:"authorized_key"`
HostPrivateKey string `json:"host_private_key"`
HostPublicKey string `json:"host_public_key"`
Port int `json:"port"`
}
SSHBootstrap is what a machine needs to be reachable: the target's public key for authorized_keys, and the host key the host generated and pinned.
type Size ¶ added in v0.3.69
type Size struct {
Name string `json:"name"`
CPU string `json:"cpu"`
Memory string `json:"memory"`
Disk string `json:"disk"`
}
Size is one machine size the plugin offers.
type TargetsChanged ¶
TargetsChanged is NotifyTargetsChanged's parameters.
type TargetsInfo ¶ added in v0.3.69
type TargetsInfo struct {
Sizes []Size `json:"sizes"`
PersistentDefault bool `json:"persistent_default"`
EgressOptions []string `json:"egress_options"`
Image string `json:"image"`
MaxEnvironments int `json:"max_environments"`
Environments int `json:"environments"`
// AddressTemplate is where a machine will be reachable, with {id}
// for the environment id: the host registers the target before the
// machine exists.
AddressTemplate string `json:"address_template"`
// SSHProxy is how the host reaches the machines: none (directly) or
// default (through LOOMUX_SSH_PROXY).
SSHProxy string `json:"ssh_proxy"`
// User and Port are sshd's in the machine.
User string `json:"user"`
Port int `json:"port"`
}
TargetsInfo is targets.describe's result: what the plugin offers right now.