Documentation
¶
Overview ¶
Package plugin is the modules a script calls, the one shape they all have, and the few ways out they all go through. Everything that comes with Corbie is built through this package, and an extension uses the same.
Index ¶
- Constants
- func Certificates(text []byte) (*x509.CertPool, error)
- func EscapedAddress(address string) string
- func FileError(err error, path string) error
- func JSON(v any) ([]byte, error)
- func Names() []string
- func Plain(v any) any
- func Refusal(err error) error
- func Register(m *Module)
- func StandIn(names func(ctx context.Context, host string) ([]string, error), ...)
- func Text(first any, what string) (string, error)
- func TextOf(v any) any
- func TooLarge(what string) error
- func TypeOf(name string) string
- type Blob
- type Bytes
- type Call
- type Channel
- type Draining
- type Error
- type Job
- func (j *Job) As(data []byte, form, typ string) (any, error)
- func (j *Job) Contents(v any) ([]byte, string, error)
- func (j *Job) Dial(ctx context.Context, address string, with ...*Secret) (net.Conn, error)
- func (j *Job) Directory(pattern string) (string, error)
- func (j *Job) End()
- func (j *Job) Entry(path string) (string, error)
- func (j *Job) File(pattern string, contents []byte) (string, error)
- func (j *Job) FileBlob(path, typ string) (*Blob, error)
- func (j *Job) Give(form, typ, what string, fill func(w io.Writer) error) (any, error)
- func (j *Job) Headers(given map[string]any, address string, encrypted bool, own ...string) (http.Header, error)
- func (j *Job) Key(value any) ([]byte, error)
- func (j *Job) Mask(text string) string
- func (j *Job) MayRead(real string) bool
- func (j *Job) Note(form, names string)
- func (j *Job) OnEnd(do func())
- func (j *Job) Path(path string, write bool) (string, error)
- func (j *Job) Program(ctx context.Context, name string, opt ProgramOptions) (*exec.Cmd, error)
- func (j *Job) Reading(v any) (io.Reader, int64, string, error)
- func (j *Job) Reveal(value any, destination string) (string, error)
- func (j *Job) RevealOver(value any, address string, encrypted bool) (string, error)
- func (j *Job) Sent(name string) bool
- func (j *Job) Source(v any) (io.ReaderAt, int64, error)
- func (j *Job) Telling(name string) *Told
- func (j *Job) Variable(name string) (string, bool, error)
- func (j *Job) Whole(group string) error
- type Module
- type Object
- type Options
- func (o Options) Bool(name string, otherwise bool) (bool, error)
- func (o Options) Duration(name string, otherwise time.Duration) (time.Duration, error)
- func (o Options) Has(name string) bool
- func (o Options) Int(name string, otherwise int) (int, error)
- func (o Options) List(name string) ([]any, error)
- func (o Options) Map(name string) (map[string]any, error)
- func (o Options) Text(name, otherwise string) (string, error)
- func (o Options) Texts(name string) ([]string, error)
- type ProgramOptions
- type Secret
- type Told
- type Whole
Constants ¶
const ( NotFound = "not_found" // the thing asked for is not there Refused = "refused" // the other side said no TimedOut = "timeout" // it took too long NotPermitted = "not_permitted" // the system, not Corbie, would not allow it BadInput = "bad_input" // the call was written wrong Failed = "failed" // anything else )
The codes an error has.
const HomeVariable = "HOME"
HomeVariable is the variable that names the runner's user's home directory.
const MaxWhole = 64 << 20
MaxWhole is the most of anything that is handed to a script whole, and so held in the job's memory: a file's contents, a body, what a program printed, something unpacked, a blob read at once, one item of a blob. It is the one such size there is. Anything larger is had as a blob, which is read a part at a time and written as it arrives.
Variables ¶
This section is empty.
Functions ¶
func Certificates ¶
Certificates reads the certificates a script gives to be trusted in place of the machine's own, as PEM text. Only those are then trusted. One that cannot be read is refused, not passed over: a call that went ahead trusting fewer certificates than were written would hide the mistake.
func EscapedAddress ¶
EscapedAddress gives an address as it goes out, with what cannot go out as it is escaped, byte for byte: a blank and a letter beyond ASCII anywhere, and before the query the marks no path may hold. An address left with one of those in its path would have the whole path written out afresh as it is sent, and what was escaped in it already, such as %2F, would come out unescaped.
func JSON ¶
JSON writes data as JSON. A handle anywhere in it is refused, as it is wherever a handle would be written out as data.
func Plain ¶
Plain gives data with every blob in it as its reference, which a blob has only once it is in the store, so that it can be written as JSON.
func Refusal ¶
Refusal gives the refusal inside an error, or nil. What a way out refused can come back to a plugin inside the error of a library it wraps, and the plugin passes the refusal on as it is.
func Register ¶
func Register(m *Module)
Register adds a module. It refuses a name a script's own things have.
func StandIn ¶
func StandIn(names func(ctx context.Context, host string) ([]string, error), connect func(ctx context.Context, address string) (net.Conn, error))
StandIn puts a stand-in in place of the network for every job of this process: names gives the addresses a name has, and connect opens a connection to an address. Every check is made as on the real network, on the name and on the addresses given. It is for tests that run scripts as they are written, against servers of the tests' own.
func TextOf ¶
TextOf gives a number or a true or false as the text it is written as, and anything else as it is. It is for a place that takes text or a handle, where a script may as well write a number.
Types ¶
type Blob ¶
type Blob struct {
Type string
Size int64
// Ref is where the blob is in the store, once it is there.
Ref *blob.Ref
// contains filtered or unexported fields
}
A Blob is a blob as a plugin and a script hold it: a type, a size, and contents that can be read. One a job makes stays with the job until its reference leaves, in an emit or in the result; only then is it sent to the store.
type Call ¶
type Call struct {
Options []string
// Variadic is for the rare call that the language itself makes with
// several things, as a tag on a template is called: first is then the
// list of everything it was called with.
Variadic bool
Do func(job *Job, first any, options Options) (any, error)
}
A Call is one thing a script can ask of a plugin: the one obvious thing first, then named options. An option the call does not list is refused.
type Channel ¶
type Channel interface {
Emit(name string, data any) error
Variable(name string) (value string, set bool, err error)
ReadBlob(ref blob.Ref, from, length int64) ([]byte, error)
WriteBlob(typ string, size int64, contents io.Reader) (blob.Ref, error)
Define(source string, files map[string]string) (blob.Ref, error)
}
The Channel is a job's own way to its runner: what it emits, its blobs, the machines it defines, and the runner's variables it is allowed.
type Draining ¶
Draining passes on what a program prints, and never holds the program up: once what it writes to takes no more, the rest is let go, and the failure kept.
type Error ¶
An Error is the one shape a plugin's error has: a short code from a short list, and what happened.
type Job ¶
type Job struct {
Context context.Context
// Perms is every layer that applies to the job.
Perms *permission.Set
// Scratch is the job's own directory: a path with no leading slash is in
// it.
Scratch string
// Wrapper is the exec wrapper: the runner's own command, put in front
// of every program started.
Wrapper []string
// Path is where programs are looked for.
SearchPath string
// Secrets are the values of the secrets the job was sent, by name.
Secrets map[string]string
// Channel is the job's own channel, which every job has.
Channel Channel
// Noted, where it is set, is told each further form a secret's value
// is about to leave in, before the value is handed over. The job's
// runner searches what the job's process prints, which the process
// cannot do for itself, and learns the forms this way.
Noted func(form, names string)
// contains filtered or unexported fields
}
A Job is what a plugin is given of the job its script runs in: the few ways out, which Corbie keeps. A plugin never opens anything by itself. It asks here for a way to connect, a path, a program or a variable; every layer of the job's permissions is checked, what was used is noted, and the thing is handed over or refused.
func (*Job) As ¶
As gives bytes to a script in the form it asked for: "text", "bytes", "json" or "blob". A byte order mark at the start of text or data is dropped.
func (*Job) Contents ¶
Contents gives the bytes of something a script hands a plugin as contents: text, bytes, a blob, or any other data, which is written as JSON. The second result is the type such contents have.
func (*Job) Dial ¶
Dial opens a connection, plain, for a plugin to use or to encrypt. The destination is checked by the name asked for and again by the address the name resolves to, and only an address that was checked is connected to. A plugin that is handed further addresses dials each the same way.
With secrets, the connection is one they may travel over: each must be bound to this destination, as it must be when its value is asked for.
func (*Job) Directory ¶
Directory makes a fresh directory inside the job's scratch directory, for a plugin's own working files. It goes with the scratch directory when the job ends.
func (*Job) Entry ¶
Entry gives the real location of a name in its directory, for the name itself to be removed. The directory is taken where it really is, and the name is not followed if it is a link: removing a link removes the link and not what it points to. It is checked against fs.write.
func (*Job) File ¶ added in v0.5.0
File makes a fresh file inside the job's scratch directory, holding the contents, for a plugin to hand a program. Only the runner's user can read it, and it goes with the scratch directory when the job ends.
func (*Job) FileBlob ¶
FileBlob makes a blob of a file, read where it lies and not copied. The file is held open until the job ends, and is read to the size it had when it was opened.
func (*Job) Give ¶
Give hands a script what a plugin produces, in the form the script asked for. fill writes it. As a blob it goes into a file in the job's scratch directory as it is written, whatever its size, and is sent to the store only if it leaves the job. In any other form it is held whole, and one too large to hold fails with the advice to ask for a blob.
func (*Job) Headers ¶
func (j *Job) Headers(given map[string]any, address string, encrypted bool, own ...string) (http.Header, error)
Headers gives the headers a script wrote for a web request that goes over a connection to an address, host:port. Each is sent as written, name and value, with a secret or without, and a value that holds secrets is revealed for the connection, as RevealOver does it. A header that is not sent as written is refused before any value is taken: the framing ones, and those the plugin says are its own to write. So is a value that holds a line break or a zero byte, which would start a header of its own.
func (*Job) Key ¶
Key gives a secret's value to be used as a key, to sign or to make a keyed hash. What comes out is ordinary data, so only a secret bound to anywhere may be used this way.
func (*Job) Mask ¶
Mask takes every secret's value out of a text that is going back to the script, or out of the job: the value as it is and in the usual encodings, each replaced with the secret's name. It catches accidents, such as a server that echoes a header.
func (*Job) MayRead ¶
MayRead says whether the job may read what is at a path, given as it really is, without noting it as used: a listing leaves out what the job may not read.
func (*Job) Note ¶
Note has a text searched for like the other forms a secret's value leaves in: a text an encoding wrote with the secrets named in it. A form that was not known is passed on to Noted.
func (*Job) OnEnd ¶
func (j *Job) OnEnd(do func())
OnEnd has something done when the job ends, however it ends.
func (*Job) Path ¶
Path gives a file's real location, to read or to write. The path is checked where it really points, after links are followed.
func (*Job) Program ¶
Program starts a program. The program the script named is checked before it is looked for, and it is what is noted as used; the exec wrapper, if there is one, goes in front.
func (*Job) Reading ¶
Reading gives something a script hands a plugin as contents to be read from start to end, with its size and its type. A blob is read a part at a time, however large it is, and never held whole.
func (*Job) Reveal ¶
Reveal gives the real text of a value that may hold secrets, for the program or the file it is going into: "exec:program" or "fs.write:/path". A plugin calls it only together with the way out the value is going into. Every secret in the value must be bound to that destination, and if one is not, nothing is given.
func (*Job) RevealOver ¶
RevealOver gives the real text of a value that may hold secrets, for the connection it is going into, to an address written host:port. encrypted is the plugin's word that the connection is encrypted at this moment, and that nothing it wraps can fall back to a plain one. Without the word, a secret goes only when its entry lets it go to the host over a connection that is not encrypted, or anywhere.
func (*Job) Source ¶
Source gives contents to be read at any place in them, with their size: a blob where it lies, anything else from memory.
func (*Job) Telling ¶
Telling gives a way to emit a text under a name as it arrives, a piece at a time. The pieces are searched for secrets across their joins: the end of what has arrived is held back until enough has followed to know it is not the start of a value.
type Module ¶
type Module struct {
Name string
// Page is the module's page of the manual, which is its specification:
// each call, its options and the permissions it needs, with examples.
Page string
// Calls are what a plugin gives a script, by name.
Calls map[string]*Call
// Library is the source of a library written in script: the body of a
// function that fills in exports.
Library string
}
A Module is a plugin, or a library written in script. A script gets it with require and its name.
type Object ¶
An Object is something that stays open, such as a connection: its own calls, and a close.
type Options ¶
Options are the named options of a call. Each getter gives the default where the option was not given, and an error where it is the wrong kind of thing.
type ProgramOptions ¶
type ProgramOptions struct {
Args []string
Env []string // name=value
Dir string
Stdin io.Reader
// Secrets are the secrets that go to the program, in its arguments, its
// variables or its input.
Secrets []*Secret
}
ProgramOptions are what a started program is given.
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
A Secret is a handle to a secret: it stands for the value and can be put wherever a value goes out. It cannot be turned into text, compared, measured or read a piece at a time. Text and handles are joined into a new handle, which is how a secret is put inside other text. A handle holds names and never a value, so however it is printed it shows only names.
func Join ¶
Join makes one handle of texts and handles. Each piece keeps the way it is written: a handle told to be encoded is encoded by itself, and the text around it is left as it was written.
func (*Secret) Encoded ¶
Encoded gives the handle with its whole text written another way: "base64", "url", as for a part of an address, or "json", as for the inside of a text in JSON. A value is escaped at most twice.
func (*Secret) MarshalJSON ¶
MarshalJSON refuses: nothing stands in for a secret where data is written out.
type Told ¶
type Told struct {
// contains filtered or unexported fields
}
Told is a text being emitted as it arrives.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package blobs is the plugin that makes and reads blobs.
|
Package blobs is the plugin that makes and reads blobs. |
|
Package bundled is every plugin that comes with Corbie.
|
Package bundled is every plugin that comes with Corbie. |
|
Package compress is the plugin for packing and unpacking: gzip, and archives of files.
|
Package compress is the plugin for packing and unpacking: gzip, and archives of files. |
|
Package crypto is the plugin for hashes, keyed hashes, random bytes, signing and checking, encryption, and writing bytes as text.
|
Package crypto is the plugin for hashes, keyed hashes, random bytes, signing and checking, encryption, and writing bytes as text. |
|
Package env is the plugin that gives a script the runner's variables.
|
Package env is the plugin that gives a script the runner's variables. |
|
Package exec is the plugin for starting a program and getting what it printed.
|
Package exec is the plugin for starting a program and getting what it printed. |
|
Package fs is the plugin for files and directories.
|
Package fs is the plugin for files and directories. |
|
Package html is the plugin for reading a page as a tree.
|
Package html is the plugin for reading a page as a tree. |
|
Package http is the plugin for web requests.
|
Package http is the plugin for web requests. |
|
Package llm is the plugin that calls a model.
|
Package llm is the plugin that calls a model. |
|
claudecode
Package claudecode is the model service that is a program: it starts Claude Code on the runner's machine and has it write one reply.
|
Package claudecode is the model service that is a program: it starts Claude Code on the runner's machine and has it write one reply. |
|
Package machines is the plugin that defines a machine while a job runs.
|
Package machines is the plugin that defines a machine while a job runs. |
|
Package net is the plugin for a raw connection, plain or encrypted.
|
Package net is the plugin for a raw connection, plain or encrypted. |
|
Package secrets is the plugin that gives a script handles to secrets.
|
Package secrets is the plugin that gives a script handles to secrets. |
|
Package ssh is the plugin for running a command on another machine.
|
Package ssh is the plugin for running a command on another machine. |
|
Package websocket is the plugin for a connection that carries messages both ways, kept alive while the script works.
|
Package websocket is the plugin for a connection that carries messages both ways, kept alive while the script works. |
|
Package xml is the plugin for reading a document as a tree, and writing a tree as a document.
|
Package xml is the plugin for reading a document as a tree, and writing a tree as a document. |