go.bigb.es/auxilia
Documentation
Index
- type Conn
- func NewConn() *Conn
- func (*Conn) Close() error
- func (*Conn) Exec(ctx context.Context, cmd legatus.Cmd) (legatus.ExecResult, error)
- func (*Conn) ExecStream(ctx context.Context, cmd legatus.Cmd, stdout, stderr io.Writer) (legatus.ExecResult, error)
- func (*Conn) Get(_ context.Context, remote string, w io.Writer) error
- func (*Conn) Put(ctx context.Context, content io.Reader, remote string, mode legatus.FileMode, opts ...legatus.PutOption) error
- type Dialer
Types
type Conn struct{}
Conn is a legatus.Conn that operates on the local machine.
func (c *Conn) Close() error
Close is a no-op: a local Conn holds no connection.
func (c *Conn) Exec(ctx context.Context, cmd legatus.Cmd) (legatus.ExecResult, error)
Exec runs cmd locally. A process that runs to completion is not an error even on a non-zero exit: the status is reported via ExecResult.ExitCode and err is nil. err is reserved for failure to launch (binary not found, IO error) or context cancellation — matching the SSH transport's Conn.Exec contract so the engine cannot tell a local Conn from a remote one.
func (c *Conn) ExecStream(ctx context.Context, cmd legatus.Cmd, stdout, stderr io.Writer) (legatus.ExecResult, error)
ExecStream runs cmd, streaming each non-nil writer live and buffering each nil writer into the returned ExecResult (the buffered contract Exec relies on). The exit-code and launch-error contract is identical to Exec.
func (c *Conn) Get(_ context.Context, remote string, w io.Writer) error
Get streams the local file at remote to w.
func (c *Conn) Put(ctx context.Context, content io.Reader, remote string, mode legatus.FileMode, opts ...legatus.PutOption) error
Put writes content to remote with mode. Without sudo it writes atomically (temp file in the destination directory, then rename). With sudo it stages to a private /tmp file then `sudo mv` into place, mirroring the SSH transport. An owner, if given, is applied with `chown` (sudo-wrapped when sudo is set).
type Dialer struct{}
Dialer is a legatus.Dialer that hands out local Conns. The host argument is ignored — every Dial targets this machine — so a workstation-local flow can run through the Runner against a synthetic host.
func (d *Dialer) Dial(_ context.Context, _ *legatus.Host) (legatus.Conn, error)
Dial returns a local Conn, ignoring h.
Package local implements legatus.Conn/legatus.Dialer on the local machine, so workstation-local steps run through the same Flow/Runner model as remote ones. Exec runs via os/exec; Put/Get use local file IO with atomic writes. No remote shell is involved, so arguments are passed structurally (os/exec argv) with no quoting; sudo wrapping mirrors the SSH transport's `sudo -- [env KEY=val …]` shape so a step behaves the same whether it targets a remote host or this one.