execcmd

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(command string, args ...string) error

ExecCmd executes a command on the local machine.

func ExecCmdContainer

func ExecCmdContainer(
	ctx context.Context,
	dockerClient *dockerclient.Client,
	containerID, userID string,
	stdIn io.Reader, stdOut, stdErr io.Writer,
	cmd string, args ...string,
) error

ExecCmdContainer executes a command in a Docker container.

func NewInStream

func NewInStream(in io.Reader, close bool) io.ReadCloser

NewInStream returns a new InStream object from a ReadCloser

func NewOutStream

func NewOutStream(out io.Writer) io.Writer

NewOutStream returns a new OutStream object from a Writer

func StartContainer

func StartContainer(
	ctx context.Context,
	dockerClient dockerclient.APIClient,
	containerID string,
	pollDur time.Duration,
) error

StartContainer starts a container and waits for it to be ready.

Types

type CommonStream

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

CommonStream is an input stream used by the DockerCli to read user input

func (*CommonStream) FD

func (s *CommonStream) FD() uintptr

FD returns the file descriptor number for this stream

func (*CommonStream) IsTerminal

func (s *CommonStream) IsTerminal() bool

IsTerminal returns true if this stream is connected to a terminal

func (*CommonStream) RestoreTerminal

func (s *CommonStream) RestoreTerminal()

RestoreTerminal restores normal mode to the terminal

func (*CommonStream) SetIsTerminal

func (s *CommonStream) SetIsTerminal(isTerminal bool)

SetIsTerminal sets the boolean used for isTerminal

func (*CommonStream) SetRawMode

func (s *CommonStream) SetRawMode()

SetRawMode sets the stream in raw mode.

type HijackedIOStreamer

type HijackedIOStreamer struct {
	InputStream  io.ReadCloser
	OutputStream io.Writer
	ErrorStream  io.Writer

	Resp types.HijackedResponse

	Tty bool
}

HijackedIOStreamer handles copying input to and output from streams to the connection.

func (*HijackedIOStreamer) Stream

func (h *HijackedIOStreamer) Stream(ctx context.Context) error

Stream handles setting up the IO and then begins streaming stdin/stdout to/from the hijacked connection, blocking until it is either done reading output, the user inputs the detach key sequence when in TTY mode, or when the given context is cancelled.

type InStream

type InStream struct {
	CommonStream
	// contains filtered or unexported fields
}

InStream is an input stream used by the DockerCli to read user input

func (*InStream) Close

func (i *InStream) Close() error

Close implements the Closer interface

func (*InStream) IsTty

func (i *InStream) IsTty() bool

IsTty checks if the input is a tty.

func (*InStream) Read

func (i *InStream) Read(p []byte) (int, error)

type OutStream

type OutStream struct {
	CommonStream
	// contains filtered or unexported fields
}

OutStream is an output stream used by the DockerCli to write normal program output.

func (*OutStream) GetTtySize

func (o *OutStream) GetTtySize() (uint, uint)

GetTtySize returns the height and width in characters of the tty

func (*OutStream) Write

func (o *OutStream) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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