systems

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerHostFor added in v0.1.2

func DockerHostFor(system config.System) string

DockerHostFor returns the DOCKER_HOST value for an already-connected system — the same value Factory.Provider resolves internally — without re-establishing an SSH tunnel, since callers (the exec-shell subprocess) only need this after a provider is already active for the system. An empty return means "use Docker's own default resolution" rather than a value to set explicitly.

func DockerHostLabel

func DockerHostLabel(system config.System) string

func ForgetPassword added in v0.1.12

func ForgetPassword(systemID string) error

ForgetPassword removes systemID's stored password, if any — called when deleting a keychain-mode system so no orphaned secret is left behind. A missing entry isn't an error: there's nothing to forget.

func IsLiveSocket added in v0.1.25

func IsLiveSocket(path string) bool

IsLiveSocket is isLiveSocket, exported for read-only external callers (cmd/whatthedock's doctor command) that need to report a tunnel socket's live/stale/missing state without going through prepareLocalSocket's own mutating stale-file cleanup — a diagnostic check must never delete anything on the strength of a single failed dial.

func PasswordFor added in v0.1.12

func PasswordFor(systemID string) (string, error)

PasswordFor fetches systemID's stored password. errNoStoredPassword specifically means "nothing saved yet" (open Systems and set one); anything else is a keychain-backend problem (no Secret Service running, etc).

func RemoteCommand added in v0.1.2

func RemoteCommand(ctx context.Context, system config.System, script string) (*exec.Cmd, error)

RemoteCommand returns an *exec.Cmd that runs script on system's SSH host, using the same ssh binary and host/port/user convention as the Docker socket tunnel above. It's for one-shot remote operations outside the tunnel — listing, reading, and writing Compose files, and running `docker compose` — not for the persistent -fN port forward.

Like SSHCommandArgs's automatic path, this always sets BatchMode=yes and ConnectTimeout=10: every caller (remote Compose file operations, `docker compose` invocations) runs headless inside a tea.Cmd goroutine with no terminal handed over, so without BatchMode a password-auth system ssh can't reach programmatically would try to prompt on /dev/tty anyway — fighting the running TUI for the real terminal — and hang until the caller's own context timeout, rather than failing fast and cleanly. ConnectTimeout bounds the separate case of an unreachable host. Keychain systems don't reach this path at all — see RemoteExec.

func RemoteExec added in v0.1.24

func RemoteExec(ctx context.Context, system config.System, script string, stdin string) ([]byte, error)

RemoteExec runs script on system's SSH host and returns its combined output, piping stdin to the remote command when non-empty. It's the single entry point every remote Compose operation goes through (see internal/ui/create.go's sshRun seam), and it picks the same authentication path Factory.Provider already picks for the Docker socket tunnel: a keychain-mode system's stored password goes through the native Go SSH client (never touching a subprocess's argv or environment — see dialKeychainTunnel), everything else shells out via RemoteCommand.

A password-prompt system (SSHAuth=="password") has no stored credential to use here — by design, that mode only ever prompts on a real terminal handoff (SSHCommand/tea.ExecProcess), which this headless path doesn't have. It still goes through RemoteCommand and, thanks to BatchMode, fails fast with a clear error instead of hanging.

func SSHCommand

func SSHCommand(system config.System) (*exec.Cmd, error)

SSHCommand builds the tunnel command for an *interactive* connection attempt — the caller hands the real terminal over to it (tea.ExecProcess in switchSystemCmd/testSystemCmd), so a password-auth system can safely prompt on it. Never use this for a connection attempt that isn't backed by a real terminal handoff — see SSHCommandArgs's doc comment for why.

func SSHCommandArgs

func SSHCommandArgs(system config.System) ([]string, error)

SSHCommandArgs builds the tunnel args for an *automatic* connection attempt — app launch (providerForMode) and any other non-interactive caller, none of which wire the child's stdio up to a real terminal (see ensureSSHTunnel/runCommand). Without BatchMode, a password-auth system ssh can't reach programmatically would still try to prompt by opening /dev/tty directly — bypassing the disconnected Cmd.Stdin entirely — and then hang indefinitely with nothing on screen to explain why, since there's no context timeout on this path either. This was reported live as "the app wants a password... it's not connecting": ssh was sitting at a bare tty prompt before the TUI had even painted a frame. BatchMode makes ssh fail fast and cleanly instead of ever attempting to prompt; ConnectTimeout bounds the separate case of an unreachable host. Neither applies to SSHCommand's interactive path, which needs the prompt to work.

func SSHCommandContext

func SSHCommandContext(ctx context.Context, system config.System) (*exec.Cmd, error)

SSHCommandContext builds the tunnel command for an *automatic* connection attempt — see SSHCommandArgs.

func SSHTarget

func SSHTarget(system config.System) string

func ShellQuote added in v0.1.2

func ShellQuote(s string) string

ShellQuote wraps s in single quotes for safe inclusion in a remote shell command, escaping any embedded single quotes POSIX-style.

func StorePassword added in v0.1.12

func StorePassword(systemID, password string) error

StorePassword saves password in the OS keychain for systemID, called when saving a system whose SSHAuth is "keychain" (see internal/ui/model.go's saveSystemDraft).

Types

type Factory

type Factory struct {
	Runner Runner
}

func NewFactory

func NewFactory() Factory

func (Factory) Provider

func (f Factory) Provider(ctx context.Context, system config.System) (app.Provider, error)

type Runner

type Runner func(context.Context, string, ...string) error

Jump to

Keyboard shortcuts

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