exec

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package exec runs commands. Docker operations go through the local docker CLI against a per-server Docker context (transport, builds, PTYs are the CLI's problem); plain SSH via the system ssh binary remains for non-Docker host chores. Both come with the user's ~/.ssh/config, agent auth, and host key verification for free.

Links to servers are assumed flaky: every SSH connection ferry spawns gets keepalives generous enough to ride out multi-minute stalls, and short docker control commands retry transparently on transient transport errors (a fresh connection typically works even while established flows are stalled).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interactive

func Interactive(args ...string) error

Interactive executes a local command wired to the terminal, stdin included.

func Run

func Run(args ...string) (string, error)

Run executes a local command and returns its combined output.

func RunInput

func RunInput(input []byte, args ...string) (string, error)

RunInput executes a local command with input on stdin (for secrets that must not appear in argv) and returns its combined output.

func RunReader

func RunReader(r io.Reader, args ...string) (string, error)

RunReader executes a local command with stdin streamed from r (context tarballs, file content) and returns its combined output.

func RunRetry

func RunRetry(fn func() (string, error)) (string, error)

RunRetry runs fn, retrying on Transient errors with backoff. Non-transient errors return immediately.

func Stream

func Stream(args ...string) error

Stream executes a local command, streaming output to the terminal.

func StreamTo

func StreamTo(w io.Writer, args ...string) error

StreamTo executes a local command, streaming stdout to w. Stderr goes to the terminal and its tail also lands in the returned error, so callers can classify failures (Transient) that exit codes alone don't reveal.

func Transient

func Transient(err error) bool

Transient reports whether an error looks like a flaky-link failure worth retrying on a fresh connection.

Types

type Docker

type Docker struct {
	Context string
	Server  *config.Server
}

Docker runs docker CLI invocations against one server's context.

func (*Docker) Args

func (d *Docker) Args(args ...string) []string

Args prefixes docker args with the context selection.

func (*Docker) Interactive

func (d *Docker) Interactive(args ...string) error

Interactive wires the command to the terminal (for exec -it, logs -f).

func (*Docker) Run

func (d *Docker) Run(args ...string) (string, error)

Run captures combined output. Transient transport failures retry on a fresh connection; callers of non-idempotent commands (docker run, network create) must tolerate an "already exists" on the retry by re-checking state.

func (*Docker) Stream

func (d *Docker) Stream(args ...string) error

Stream streams output to the terminal. No retry: callers decide whether re-running an attached command is safe.

type Host

type Host struct {
	Server *config.Server
}

Host runs plain SSH commands on a server for non-Docker chores: provisioning, mkdir, shipping env files, hooks, the lock dir, the audit log.

func (*Host) Interactive

func (h *Host) Interactive(command string) error

Interactive opens an interactive session (or command) with a PTY.

func (*Host) Run

func (h *Host) Run(command string) (string, error)

Run executes a shell command on the host and captures combined output.

func (*Host) RunInput

func (h *Host) RunInput(input []byte, command string) (string, error)

RunInput executes a shell command on the host with input on stdin.

func (*Host) RunReader

func (h *Host) RunReader(r io.Reader, command string) (string, error)

RunReader executes a shell command on the host with stdin streamed from r.

func (*Host) Stream

func (h *Host) Stream(command string) error

Stream executes a shell command on the host, streaming output.

func (*Host) StreamTo

func (h *Host) StreamTo(w io.Writer, command string) error

StreamTo executes a shell command on the host, streaming stdout to w.

func (*Host) WriteFile

func (h *Host) WriteFile(path string, content []byte, mode string) error

WriteFile ships content to a path on the host with the given mode, creating parent directories. Content goes over stdin, never through argv.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL