hostexec

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package hostexec defines the execution surface (HostClient, Executor) shared by the TUI, web server, CUE runner, and provider-specific transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer added in v0.3.4

type Dialer interface {
	DialHost(user, hostAlias string, overridePort int, identityFile string) (HostClient, error)
}

Dialer establishes a HostClient for an SSH target.

type DialerFunc added in v0.3.4

type DialerFunc func(user, hostAlias string, overridePort int, identityFile string) (HostClient, error)

DialerFunc adapts a plain function to the Dialer interface.

func (DialerFunc) DialHost added in v0.3.4

func (f DialerFunc) DialHost(user, hostAlias string, overridePort int, identityFile string) (HostClient, error)

DialHost calls f.

type Executor

type Executor interface {
	Dial(user string, r hosts.Record) (HostClient, error)
	RunInteractive(user string, r hosts.Record) error
	RunTunnel(ctx context.Context, user string, r hosts.Record, localFwd string, out io.Writer) error
	DialUpstream(ctx context.Context, user string, r hosts.Record, address string) (net.Conn, error)
}

Executor creates HostClients and runs interactive SSH-style sessions or tunnels.

type ExecutorResolver added in v0.3.4

type ExecutorResolver interface {
	ResolveExecutor(rec hosts.Record, reg Registry) Executor
}

ExecutorResolver resolves a provider-specific Executor for a record, returning nil to fall back to SSH.

type ExecutorResolverFunc added in v0.3.4

type ExecutorResolverFunc func(rec hosts.Record, reg Registry) Executor

ExecutorResolverFunc adapts a plain function to the ExecutorResolver interface.

func (ExecutorResolverFunc) ResolveExecutor added in v0.3.4

func (f ExecutorResolverFunc) ResolveExecutor(rec hosts.Record, reg Registry) Executor

ResolveExecutor calls f.

type HostClient

type HostClient interface {
	Run(cmd string) ([]byte, error)
	// RunWithStreams runs a remote command with stdin/stdout/stderr wired through.
	// stderr may be nil to discard remote stderr.
	RunWithStreams(cmd string, stdin io.Reader, stdout, stderr io.Writer) error
	Upload(localPath, remotePath string) error
	Download(remotePath, localPath string) error
	ListRemoteDir(path string) ([]RemoteFileEntry, error)
	StatRemote(path string) (RemoteFileEntry, error)
	MkdirAllRemote(path string) error
	RemoveRemote(path string, recursive bool) error
	Close() error
}

HostClient defines running commands and file operations on a single host.

type InteractiveRunner added in v0.3.4

type InteractiveRunner interface {
	RunInteractive(user string, r hosts.Record, recorder any) error
}

InteractiveRunner runs an interactive SSH session on a record.

type InteractiveRunnerFunc added in v0.3.4

type InteractiveRunnerFunc func(user string, r hosts.Record, recorder any) error

InteractiveRunnerFunc adapts a plain function to the InteractiveRunner interface.

func (InteractiveRunnerFunc) RunInteractive added in v0.3.4

func (f InteractiveRunnerFunc) RunInteractive(user string, r hosts.Record, recorder any) error

RunInteractive calls f.

type Reconfigurer added in v0.3.4

type Reconfigurer interface {
	ReconfigureFromConfig(cfg *config.File)
}

Reconfigurer applies updated configuration to provider factories.

type ReconfigurerFunc added in v0.3.4

type ReconfigurerFunc func(cfg *config.File)

ReconfigurerFunc adapts a plain function to the Reconfigurer interface.

func (ReconfigurerFunc) ReconfigureFromConfig added in v0.3.4

func (f ReconfigurerFunc) ReconfigureFromConfig(cfg *config.File)

ReconfigureFromConfig calls f.

type Registry added in v0.3.4

type Registry interface {
	ForRecord(r hosts.Record) Executor
	Reconfigure(cfg *config.File)
	RunSSHTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error
	BorrowSSH(user string, hop hosts.Record) (any, bool)
}

Registry handles resolving and dispatching host execution.

type RemoteFileEntry

type RemoteFileEntry struct {
	Name       string    `json:"name"`
	Path       string    `json:"path"`
	IsDir      bool      `json:"is_dir"`
	Size       int64     `json:"size"`
	Mode       string    `json:"mode"`
	ModifiedAt time.Time `json:"modified_at"`
}

RemoteFileEntry describes one filesystem object on the remote host.

type SSHBorrower added in v0.3.4

type SSHBorrower interface {
	BorrowSSH(user string, hop hosts.Record) (any, bool)
}

SSHBorrower hands out a cached SSH client for a hop, if one is available.

type SSHBorrowerFunc added in v0.3.4

type SSHBorrowerFunc func(user string, hop hosts.Record) (any, bool)

SSHBorrowerFunc adapts a plain function to the SSHBorrower interface.

func (SSHBorrowerFunc) BorrowSSH added in v0.3.4

func (f SSHBorrowerFunc) BorrowSSH(user string, hop hosts.Record) (any, bool)

BorrowSSH calls f.

type StandardRegistry added in v0.3.4

type StandardRegistry struct {
	Resolver     ExecutorResolver
	Reconfigurer Reconfigurer
	Dialer       Dialer
	Interactive  InteractiveRunner
	Tunnel       TunnelRunner
	SSHBorrower  SSHBorrower
}

StandardRegistry implements Registry by delegating to injected collaborators. A nil collaborator disables the corresponding capability.

func (*StandardRegistry) BorrowSSH added in v0.3.4

func (r *StandardRegistry) BorrowSSH(user string, hop hosts.Record) (any, bool)

BorrowSSH delegates to the configured SSHBorrower if provided.

func (*StandardRegistry) ForRecord added in v0.3.4

func (r *StandardRegistry) ForRecord(rec hosts.Record) Executor

ForRecord returns the Executor for a search row. Provider-specific dispatch is handled by the Resolver. SSH is the fallback when no provider claims the record.

func (*StandardRegistry) Reconfigure added in v0.3.4

func (r *StandardRegistry) Reconfigure(cfg *config.File)

Reconfigure propagates config to all registered provider factories.

func (*StandardRegistry) RunSSHTunnel added in v0.3.4

func (r *StandardRegistry) RunSSHTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error

RunSSHTunnel runs the SSH local-forward tunnel.

type TunnelRunner added in v0.3.4

type TunnelRunner interface {
	RunTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error
}

TunnelRunner runs an SSH local-forward tunnel until ctx is cancelled.

type TunnelRunnerFunc added in v0.3.4

type TunnelRunnerFunc func(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error

TunnelRunnerFunc adapts a plain function to the TunnelRunner interface.

func (TunnelRunnerFunc) RunTunnel added in v0.3.4

func (f TunnelRunnerFunc) RunTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, out io.Writer) error

RunTunnel calls f.

Jump to

Keyboard shortcuts

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