remotecommand

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultStreamCreationTimeout = 30 * time.Second

	// The SPDY subprotocol "channel.k8s.io" is used for remote command
	// attachment/execution. This represents the initial unversioned subprotocol,
	// which has the known bugs http://issues.k8s.io/13394 and
	// http://issues.k8s.io/13395.
	StreamProtocolV1Name = "channel.k8s.io"

	// The SPDY subprotocol "v2.channel.k8s.io" is used for remote command
	// attachment/execution. It is the second version of the subprotocol and
	// resolves the issues present in the first version.
	StreamProtocolV2Name = "v2.channel.k8s.io"

	// The SPDY subprotocol "v3.channel.k8s.io" is used for remote command
	// attachment/execution. It is the third version of the subprotocol and
	// adds support for resizing container terminals.
	StreamProtocolV3Name = "v3.channel.k8s.io"

	// The SPDY subprotocol "v4.channel.k8s.io" is used for remote command
	// attachment/execution. It is the 4th version of the subprotocol and
	// adds support for exit codes.
	StreamProtocolV4Name = "v4.channel.k8s.io"

	NonZeroExitCodeReason = metav1.StatusReason("NonZeroExitCode")
	ExitCodeCauseType     = metav1.CauseType("ExitCode")
)

Variables

Functions

This section is empty.

Types

type CodeExitError

type CodeExitError struct {
	Err  error
	Code int
}

CodeExitError is an implementation of ExitError consisting of an error object and an exit code (the upper bits of os.exec.ExitStatus).

func (CodeExitError) Error

func (e CodeExitError) Error() string

func (CodeExitError) ExitStatus

func (e CodeExitError) ExitStatus() int

func (CodeExitError) Exited

func (e CodeExitError) Exited() bool

func (CodeExitError) String

func (e CodeExitError) String() string

type DefaultRemoteExecutor

type DefaultRemoteExecutor struct{}

DefaultRemoteExecutor is the standard implementation of remote command execution

func (DefaultRemoteExecutor) Execute

func (d DefaultRemoteExecutor) Execute(method string, url *url.URL, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue TerminalSizeQueue) error

type Executor

type Executor interface {
	// Stream initiates the transport of the standard shell streams. It will transport any
	// non-nil stream to a remote system, and return an error if a problem occurs.
	Stream(options StreamOptions) error
}

Executor is an interface for transporting shell-style streams.

func NewSPDYExecutor

func NewSPDYExecutor(method string, url *url.URL) (Executor, error)

NewSPDYExecutor connects to the provided server and upgrades the connection to multiplexed bidirectional streams.

func NewSPDYExecutorForProtocols

func NewSPDYExecutorForProtocols(transport http.RoundTripper, upgrader spdy.Upgrader, method string, url *url.URL, protocols ...string) (Executor, error)

NewSPDYExecutorForProtocols connects to the provided server and upgrades the connection to multiplexed bidirectional streams using only the provided protocols. Exposed for testing, most callers should use NewSPDYExecutor or NewSPDYExecutorForTransports.

func NewSPDYExecutorForTransports

func NewSPDYExecutorForTransports(tranport http.RoundTripper, upgrader spdy.Upgrader, method string, url *url.URL) (Executor, error)

NewSPDYExecutorForTransports connects to the provided server using the given transport, upgrades the response using the given upgrader to multiplexed bidirectional streams.

type ExitError

type ExitError interface {
	String() string
	Error() string
	Exited() bool
	ExitStatus() int
}

ExitError is an interface that presents an API similar to os.ProcessState, which is what ExitError from os/exec is. This is designed to make testing a bit easier and probably loses some of the cross-platform properties of the underlying library.

type RemoteExecutor

type RemoteExecutor interface {
	Execute(method string, url *url.URL, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue TerminalSizeQueue) error
}

RemoteExecutor defines the interface accepted by the Exec command

func NewDefaultRemoteExecutor

func NewDefaultRemoteExecutor() RemoteExecutor

type StreamOptions

type StreamOptions struct {
	Stdin             io.Reader
	Stdout            io.Writer
	Stderr            io.Writer
	Tty               bool
	TerminalSizeQueue TerminalSizeQueue
	Header            http.Header
}

StreamOptions holds information pertaining to the current streaming session: input/output streams, if the client is requesting a TTY, and a terminal size queue to support terminal resizing.

type TerminalSize

type TerminalSize struct {
	Width  uint16
	Height uint16
}

TerminalSize represents the width and height of a terminal

type TerminalSizeQueue

type TerminalSizeQueue interface {
	// Next returns the new terminal size after the terminal has been resized. It returns nil when
	// monitoring has been stopped.
	Next() *TerminalSize
}

TerminalSizeQueue is capable of returning terminal resize events as they occur.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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