Documentation
¶
Overview ¶
Package hostexec defines the execution surface (HostClient, Executor) shared by the TUI, web server, CUE runner, and provider-specific transports.
Index ¶
- type Dialer
- type DialerFunc
- type Executor
- type ExecutorResolver
- type ExecutorResolverFunc
- type HostClient
- type InteractiveRunner
- type InteractiveRunnerFunc
- type Reconfigurer
- type ReconfigurerFunc
- type Registry
- type RemoteFileEntry
- type SSHBorrower
- type SSHBorrowerFunc
- type StandardRegistry
- func (r *StandardRegistry) BorrowSSH(user string, hop hosts.Record) (any, bool)
- func (r *StandardRegistry) ForRecord(rec hosts.Record) Executor
- func (r *StandardRegistry) Reconfigure(cfg *config.File)
- func (r *StandardRegistry) RunSSHTunnel(ctx context.Context, user, host string, sshPort int, localFwd string, ...) error
- type TunnelRunner
- type TunnelRunnerFunc
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
ExecutorResolver resolves a provider-specific Executor for a record, returning nil to fall back to SSH.
type ExecutorResolverFunc ¶ added in v0.3.4
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
InteractiveRunnerFunc adapts a plain function to the InteractiveRunner interface.
func (InteractiveRunnerFunc) RunInteractive ¶ added in v0.3.4
RunInteractive calls f.
type Reconfigurer ¶ added in v0.3.4
Reconfigurer applies updated configuration to provider factories.
type ReconfigurerFunc ¶ added in v0.3.4
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
SSHBorrower hands out a cached SSH client for a hop, if one is available.
type SSHBorrowerFunc ¶ added in v0.3.4
SSHBorrowerFunc adapts a plain function to the SSHBorrower interface.
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
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.
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.