Documentation
¶
Overview ¶
internal/transport/docker.go
internal/transport/ssh.go
Index ¶
- func ParseArch(output string) string
- func ParsePlatform(output string) string
- func ParsePwshArch(output string) string
- func ParsePwshVersion(output string) (int, bool)
- func ParseShellName(output string) string
- func PwshArchCommand() string
- func PwshPlatformCommand() string
- func StripAnsi(s string) string
- type DockerTransport
- func (t *DockerTransport) Close() error
- func (t *DockerTransport) Connect(ctx context.Context) error
- func (t *DockerTransport) Exec(ctx context.Context, command string, opts *ExecOptions) (*ExecResult, error)
- func (t *DockerTransport) HealthCheck(ctx context.Context) error
- func (t *DockerTransport) Info() *RemoteInfo
- func (t *DockerTransport) ReadFile(ctx context.Context, path string) ([]byte, error)
- func (t *DockerTransport) State() TransportState
- func (t *DockerTransport) Type() TransportType
- func (t *DockerTransport) WriteFile(ctx context.Context, path string, content []byte) error
- type ExecOptions
- type ExecResult
- type RemoteInfo
- type SSHTransport
- func (t *SSHTransport) Close() error
- func (t *SSHTransport) Connect(ctx context.Context) error
- func (t *SSHTransport) Exec(ctx context.Context, command string, opts *ExecOptions) (*ExecResult, error)
- func (t *SSHTransport) ForwardPort(localAddr, remoteAddr string) (net.Listener, error)
- func (t *SSHTransport) HealthCheck(ctx context.Context) error
- func (t *SSHTransport) Info() *RemoteInfo
- func (t *SSHTransport) ReadFile(ctx context.Context, path string) ([]byte, error)
- func (t *SSHTransport) State() TransportState
- func (t *SSHTransport) Type() TransportType
- func (t *SSHTransport) WriteFile(ctx context.Context, path string, content []byte) error
- type Transport
- type TransportState
- type TransportType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePlatform ¶
func ParsePwshArch ¶
func ParsePwshVersion ¶
func ParseShellName ¶
func PwshArchCommand ¶
func PwshArchCommand() string
func PwshPlatformCommand ¶
func PwshPlatformCommand() string
Types ¶
type DockerTransport ¶
type DockerTransport struct {
// contains filtered or unexported fields
}
DockerTransport implements Transport using the Docker Engine API.
func NewDockerTransport ¶
func NewDockerTransport(cfg target.TargetConfig) *DockerTransport
NewDockerTransport creates a new Docker transport for the given config.
func (*DockerTransport) Close ¶
func (t *DockerTransport) Close() error
Close closes the Docker client.
func (*DockerTransport) Connect ¶
func (t *DockerTransport) Connect(ctx context.Context) error
Connect verifies the container is running and detects the remote environment.
func (*DockerTransport) Exec ¶
func (t *DockerTransport) Exec(ctx context.Context, command string, opts *ExecOptions) (*ExecResult, error)
Exec executes a command in the container via the Docker Exec API.
func (*DockerTransport) HealthCheck ¶
func (t *DockerTransport) HealthCheck(ctx context.Context) error
HealthCheck verifies the container is still running.
func (*DockerTransport) Info ¶
func (t *DockerTransport) Info() *RemoteInfo
func (*DockerTransport) ReadFile ¶
ReadFile reads a file from the container using CopyFromContainer.
func (*DockerTransport) State ¶
func (t *DockerTransport) State() TransportState
func (*DockerTransport) Type ¶
func (t *DockerTransport) Type() TransportType
type ExecOptions ¶
type ExecResult ¶
type RemoteInfo ¶
type SSHTransport ¶
type SSHTransport struct {
// contains filtered or unexported fields
}
SSHTransport implements Transport over SSH using golang.org/x/crypto/ssh.
func NewSSHTransport ¶
func NewSSHTransport(cfg target.TargetConfig) *SSHTransport
NewSSHTransport creates a new SSH transport for the given config.
func (*SSHTransport) Close ¶
func (t *SSHTransport) Close() error
Close terminates the SSH connection.
func (*SSHTransport) Connect ¶
func (t *SSHTransport) Connect(ctx context.Context) error
Connect establishes the SSH connection, SFTP subsystem, and detects remote environment.
func (*SSHTransport) Exec ¶
func (t *SSHTransport) Exec(ctx context.Context, command string, opts *ExecOptions) (*ExecResult, error)
Exec executes a command on the remote host via a new SSH session channel.
func (*SSHTransport) ForwardPort ¶
func (t *SSHTransport) ForwardPort(localAddr, remoteAddr string) (net.Listener, error)
ForwardPort creates a local TCP listener that forwards to a remote address via SSH. Returns the listener (caller must close it) and starts forwarding in the background.
func (*SSHTransport) HealthCheck ¶
func (t *SSHTransport) HealthCheck(ctx context.Context) error
HealthCheck verifies the connection is still alive.
func (*SSHTransport) Info ¶
func (t *SSHTransport) Info() *RemoteInfo
func (*SSHTransport) State ¶
func (t *SSHTransport) State() TransportState
func (*SSHTransport) Type ¶
func (t *SSHTransport) Type() TransportType
type Transport ¶
type Transport interface {
Type() TransportType
State() TransportState
Connect(ctx context.Context) error
Close() error
Exec(ctx context.Context, command string, opts *ExecOptions) (*ExecResult, error)
ReadFile(ctx context.Context, path string) ([]byte, error)
WriteFile(ctx context.Context, path string, content []byte) error
Info() *RemoteInfo
HealthCheck(ctx context.Context) error
}
func NewTransport ¶
func NewTransport(cfg target.TargetConfig) (Transport, error)
NewTransport creates the appropriate transport for a target config.
type TransportState ¶
type TransportState string
const ( StateConnecting TransportState = "connecting" StateConnected TransportState = "connected" StateDisconnected TransportState = "disconnected" StateError TransportState = "error" )
type TransportType ¶
type TransportType string
const ( TransportSSH TransportType = "ssh" TransportDocker TransportType = "docker" )