remotecommand

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

remotecommand

enable client-go remotecommand stream to close

修改了client-go tools remotecommand 增加了主动关闭stream的功能

通过StreamOptions.CloseChan chan bool,实现关闭stream

remotecommand.StreamOptions{
		Stdin:             stdin,
		Stdout:            stdout,
		Stderr:            stderr,
		Tty:               true,
		CloseChan:         closeChan,
		TerminalSizeQueue: terminalSizeQueue,
	}

如果需要强制关闭只需要关闭channel:close(closeChan)即可

Documentation

Overview

Package remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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. If tty
	// is set, the stderr stream is not used (raw TTY manages stdout and stderr over the
	// stdout stream).
	Stream(options StreamOptions) error
	// StreamContext initiates the transport of the standard shell streams through Context.
	StreamContext(ctx context.Context, options StreamOptions) error
	// StreamRequest initiates the transport of the standard shell streams through Request.
	StreamRequest(req *http.Request, options StreamOptions) error
}

Executor is an interface for transporting shell-style streams.

func NewSPDYExecutor

func NewSPDYExecutor(config *restclient.Config, 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(transport 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 StreamOptions

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

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.

Jump to

Keyboard shortcuts

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