go.bigb.es/auxilia

v0.3.0
Doc Versions Source

Documentation

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.

Types

T type Conn

src
type Conn struct{}

Conn is a legatus.Conn that operates on the local machine.

f func NewConn

src
func NewConn() *Conn

NewConn returns a local Conn.

m func (*Conn) Close

src
func (c *Conn) Close() error

Close is a no-op: a local Conn holds no connection.

m func (*Conn) Exec

src
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.

m func (*Conn) ExecStream

src
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.

m func (*Conn) Get

src
func (c *Conn) Get(_ context.Context, remote string, w io.Writer) error

Get streams the local file at remote to w.

m func (*Conn) Put

src
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).

T type Dialer

src
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.

f func NewDialer

src

NewDialer returns a local Dialer.

m func (*Dialer) Dial

src
func (d *Dialer) Dial(_ context.Context, _ *legatus.Host) (legatus.Conn, error)

Dial returns a local Conn, ignoring h.

Source Files