genconn

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

generic connection code (WSL + SSH)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildShellCommand

func BuildShellCommand(opts CommandSpec) (string, error)

func ContextWithConnData

func ContextWithConnData(ctx context.Context, blockId string) context.Context

func GetConnData

func GetConnData(ctx context.Context) *connData

func MakeStderrSyncBuffer

func MakeStderrSyncBuffer(proc ShellProcessController) (*syncbuf.SyncBuffer, error)

func MakeStdoutSyncBuffer

func MakeStdoutSyncBuffer(proc ShellProcessController) (*syncbuf.SyncBuffer, error)

func ProcessContextWait

func ProcessContextWait(ctx context.Context, proc ShellProcessController) error

func RunSimpleCommand

func RunSimpleCommand(ctx context.Context, client ShellClient, spec CommandSpec) (string, string, error)

Types

type CommandSpec

type CommandSpec struct {
	Cmd string
	Env map[string]string
	Cwd string
}

type SSHProcessController

type SSHProcessController struct {
	// contains filtered or unexported fields
}

SSHProcessController implements ShellCmd for SSH connections

func MakeSSHCmdClient

func MakeSSHCmdClient(client *ssh.Client, cmdSpec CommandSpec) (*SSHProcessController, error)

MakeSSHCmdClient creates a new instance of SSHCmdClient

func (*SSHProcessController) Kill

func (s *SSHProcessController) Kill()

Kill terminates the command

func (*SSHProcessController) Start

func (s *SSHProcessController) Start() error

Start begins execution of the command

func (*SSHProcessController) StderrPipe

func (s *SSHProcessController) StderrPipe() (io.Reader, error)

func (*SSHProcessController) StdinPipe

func (s *SSHProcessController) StdinPipe() (io.WriteCloser, error)

func (*SSHProcessController) StdoutPipe

func (s *SSHProcessController) StdoutPipe() (io.Reader, error)

func (*SSHProcessController) Wait

func (s *SSHProcessController) Wait() error

Wait waits for the command to complete

type SSHShellClient

type SSHShellClient struct {
	// contains filtered or unexported fields
}

func MakeSSHShellClient

func MakeSSHShellClient(client *ssh.Client) *SSHShellClient

func (*SSHShellClient) MakeProcessController

func (c *SSHShellClient) MakeProcessController(cmdSpec CommandSpec) (ShellProcessController, error)

type ShellClient

type ShellClient interface {
	MakeProcessController(cmd CommandSpec) (ShellProcessController, error)
}

type ShellProcessController

type ShellProcessController interface {
	Start() error
	Wait() error
	Kill()

	// these are not required to be called, if they are not called, the impl will set to discard output
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.Reader, error)
	StderrPipe() (io.Reader, error)
}

type WSLProcessController

type WSLProcessController struct {
	// contains filtered or unexported fields
}

func MakeWSLProcessController

func MakeWSLProcessController(distro *wsl.Distro, cmdSpec CommandSpec) (*WSLProcessController, error)

func (*WSLProcessController) Kill

func (w *WSLProcessController) Kill()

func (*WSLProcessController) Start

func (w *WSLProcessController) Start() error

func (*WSLProcessController) StderrPipe

func (w *WSLProcessController) StderrPipe() (io.Reader, error)

func (*WSLProcessController) StdinPipe

func (w *WSLProcessController) StdinPipe() (io.WriteCloser, error)

func (*WSLProcessController) StdoutPipe

func (w *WSLProcessController) StdoutPipe() (io.Reader, error)

func (*WSLProcessController) Wait

func (w *WSLProcessController) Wait() error

type WSLShellClient

type WSLShellClient struct {
	// contains filtered or unexported fields
}

func MakeWSLShellClient

func MakeWSLShellClient(distro *wsl.Distro) *WSLShellClient

func (*WSLShellClient) MakeProcessController

func (c *WSLShellClient) MakeProcessController(cmdSpec CommandSpec) (ShellProcessController, error)

Jump to

Keyboard shortcuts

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