execcmd

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(ctx context.Context, command string, args ...string) error

ExecCmd executes a local command with inherited standard output and error.

func ExecCmdContainer

func ExecCmdContainer(
	ctx context.Context,
	le *logrus.Entry,
	dockerClient client.APIClient,
	containerID string,
	userID string,
	stdIn io.Reader,
	stdOut io.Writer,
	stdErr io.Writer,
	cmd string,
	args ...string,
) error

ExecCmdContainer executes a command in a Docker container and returns its exit status.

func InspectExecExit added in v1.15.0

func InspectExecExit(ctx context.Context, inspector ExecInspector, execID string) error

InspectExecExit returns an error when the Docker exec process did not exit successfully.

func NewInStream

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

NewInStream constructs an input stream around a reader.

func NewOutStream

func NewOutStream(le *logrus.Entry, out io.Writer) io.Writer

NewOutStream constructs an output stream around a writer.

Types

type CommandExitError added in v1.15.0

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

CommandExitError reports a non-zero Docker exec exit status.

func NewCommandExitError added in v1.15.0

func NewCommandExitError(exitCode int) *CommandExitError

NewCommandExitError constructs an error for a non-zero Docker exec exit status.

func (*CommandExitError) Error added in v1.15.0

func (e *CommandExitError) Error() string

Error returns the command exit error message.

func (*CommandExitError) ExitCode added in v1.15.0

func (e *CommandExitError) ExitCode() int

ExitCode returns the Docker exec exit status.

type CommonStream

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

CommonStream tracks terminal state shared by input and output streams.

func (*CommonStream) FD

func (s *CommonStream) FD() uintptr

FD returns the stream file descriptor.

func (*CommonStream) IsTerminal

func (s *CommonStream) IsTerminal() bool

IsTerminal reports whether the stream is connected to a terminal.

func (*CommonStream) RestoreTerminal

func (s *CommonStream) RestoreTerminal() error

RestoreTerminal restores the terminal mode saved by SetRawMode.

func (*CommonStream) SetIsTerminal

func (s *CommonStream) SetIsTerminal(isTerminal bool)

SetIsTerminal overrides whether the stream is connected to a terminal.

func (*CommonStream) SetRawMode

func (s *CommonStream) SetRawMode() error

SetRawMode places the terminal in raw mode.

type ExecInspector added in v1.15.0

type ExecInspector interface {
	ContainerExecInspect(context.Context, string) (container.ExecInspect, error)
}

ExecInspector inspects the state of a Docker exec process.

type HijackedIOStreamer

type HijackedIOStreamer struct {
	InputStream  io.ReadCloser
	OutputStream io.Writer
	ErrorStream  io.Writer
	Resp         types.HijackedResponse
	TTY          bool
	// contains filtered or unexported fields
}

HijackedIOStreamer copies input and output over a Docker hijacked connection.

func NewHijackedIOStreamer added in v1.15.0

func NewHijackedIOStreamer(
	le *logrus.Entry,
	resp types.HijackedResponse,
	useTTY bool,
) *HijackedIOStreamer

NewHijackedIOStreamer constructs a streamer for a Docker hijacked connection.

func (*HijackedIOStreamer) Stream

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

Stream copies stdin, stdout, and stderr until the command, input, or context ends.

type InStream

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

InStream reads command input and optionally owns the underlying reader.

func (*InStream) Close

func (i *InStream) Close() error

Close closes the underlying reader when ownership was requested.

func (*InStream) IsTTY added in v1.15.0

func (i *InStream) IsTTY() bool

IsTTY reports whether the input is a terminal.

func (*InStream) Read

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

Read reads from the underlying input.

type OutStream

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

OutStream writes command output and exposes terminal dimensions.

func (*OutStream) GetTTYSize added in v1.15.0

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

GetTTYSize returns the terminal height and width in characters.

func (*OutStream) Write

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

Write writes output to the underlying writer.

Jump to

Keyboard shortcuts

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