Documentation
¶
Overview ¶
Package pluginspec is the lockfile plugin contract: the signed manifest a plugin ships with, and the rule that turns a plugin's stdout and exit status into an answer.
A plugin answers exactly one yes/no question about one file. Its only output is the byte 1 or 0 on stdout (one trailing newline tolerated) followed by exit status 0. Anything else is a failure, and every plugin-caused failure reaches the agent as the single code AgentErrorCode; the precise cause is kept for the audit only.
Index ¶
Constants ¶
const ( MaxTimeout = 120 * time.Second MaxMemory = 2 << 30 )
Bounds on what a manifest may ask for.
const AgentErrorCode = "plugin_error"
AgentErrorCode is the only error an agent sees for a plugin-caused failure, whatever the cause.
const ProtocolVersion = 1
ProtocolVersion is the only plugin protocol this package knows.
Variables ¶
var MediaTypes = map[string]bool{ "*/*": true, "application/pdf": true, "application/zip": true, "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true, }
MediaTypes is the closed list of values allowed in a manifest's accepts.
Functions ¶
func ParseBytes ¶
ParseBytes reads a size such as "512MiB", "1GiB", "64KiB" or "4096".
func ValidVersion ¶
ValidVersion reports whether s is an exact X.Y.Z version.
Types ¶
type FailureCause ¶
type FailureCause string
FailureCause is why a plugin gave no answer. It is for the audit only.
const ( CauseNone FailureCause = "" CauseExitCode FailureCause = "exit_code" CauseSignal FailureCause = "signal" CauseTimeout FailureCause = "timeout" CauseInvalidOutput FailureCause = "invalid_output" CauseOutputTooLong FailureCause = "output_too_long" CauseSandbox FailureCause = "sandbox" )
type Manifest ¶
type Manifest struct {
Name string
Version string
Protocol int
Question string
One string
Zero string
Accepts []string
Limits Limits
}
Manifest is a plugin's plugin.toml.
func ParseManifest ¶
ParseManifest decodes and validates a plugin.toml. Unknown keys, notably params, are an error: plugins take no parameters.
type Outcome ¶
type Outcome struct {
Answer *bool
Cause FailureCause
}
Outcome is the result of one plugin run: an answer, or no answer and a cause. Answer is nil exactly when Cause is not CauseNone.
func ParseAnswer ¶
ParseAnswer applies the contract to what a plugin process produced: stdout must be exactly "1" or "0", optionally followed by one "\n", and the process must have exited with status 0. truncated reports that the plugin wrote more than the read cap.