transport

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(ctx context.Context, copyWriter CopyWriter, dst string, request ExecRequest) error

Copy executes a copy request.

func NewExecError

func NewExecError(err error, exitCode int) error

NewExecError creates a new ExecError with the provided exitCode and wrapped error.

func Run

func Run(ctx context.Context, request ExecRequest) (stdout string, stderr string, err error)

Run executes a remote exec and blocks waiting for the results.

func Stream

func Stream(ctx context.Context, request ExecRequest) (stdout io.Reader, stderr io.Reader, errC chan error)

Stream executes a streaming remote request.

Types

type Command

type Command interface {
	Cmd() string
}

Command represents a command to run.

type CopyWriter

type CopyWriter func(errorC chan error)

CopyWriter a function that can write the stdin for a copy request.

func TarCopyWriter

func TarCopyWriter(src Copyable, dst string, stdin io.WriteCloser) CopyWriter

TarCopyWriter creates a new CopyWriter that uses tar to copy a file.

type Copyable

type Copyable interface {
	io.ReadSeekCloser
	Size() int64
}

Copyable is an interface for a copyable file.

type ExecError

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

ExecError An exec error is a wrapper error that all transport implementations should return if the exec failed with an exit code.

func (*ExecError) Append

func (e *ExecError) Append(err error)

func (*ExecError) Error

func (e *ExecError) Error() string

Error returns the wrapped error.

func (*ExecError) ExitCode

func (e *ExecError) ExitCode() int

func (*ExecError) Unwrap

func (e *ExecError) Unwrap() error

type ExecRequest

type ExecRequest interface {
	// Exec executes a remote command
	Exec(ctx context.Context) *ExecResponse
	// Streams retrieves the IO streams for the ExecRequest
	Streams() *ExecStreams
}

ExecRequest can be used to execute a remote command.

type ExecResponse

type ExecResponse struct {
	Stdout  io.Reader
	Stderr  io.Reader
	ExecErr chan error
}

ExecResponse a Response that a transport exec request should return.

func NewExecResponse

func NewExecResponse() *ExecResponse

func (*ExecResponse) WaitForResults

func (e *ExecResponse) WaitForResults() (stdout, stderr string, err error)

WaitForResults waits for the execution to finish and returns the stdout, stderr and the execution error if there is any.

type ExecStreams

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

ExecStreams The IO streams associated with an ExecRequest.

func NewExecStreams

func NewExecStreams(stdin bool) *ExecStreams

func (*ExecStreams) Close

func (e *ExecStreams) Close() error

Close closes all the streams and returns the aggregate error if any error occurred while closing any of the streams.

func (*ExecStreams) Stderr

func (e *ExecStreams) Stderr() io.Reader

func (*ExecStreams) StderrWriter

func (e *ExecStreams) StderrWriter() io.WriteCloser

func (*ExecStreams) Stdin

func (e *ExecStreams) Stdin() io.Reader

func (*ExecStreams) StdinWriter

func (e *ExecStreams) StdinWriter() io.WriteCloser

func (*ExecStreams) Stdout

func (e *ExecStreams) Stdout() io.Reader

func (*ExecStreams) StdoutWriter

func (e *ExecStreams) StdoutWriter() io.WriteCloser

type Transport

type Transport interface {
	Copy(ctx context.Context, body Copyable, dest string) error
	Run(ctx context.Context, cmd Command) (stdout, stderr string, err error)
	Stream(ctx context.Context, cmd Command) (stdout, stderr io.Reader, errC chan error)
	Type() TransportType
	io.Closer
}

Transport is a generic transport interface.

type TransportType

type TransportType string

TransportType is the string representation of the transport type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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