Documentation ¶
Overview ¶
Package exec provides utilities to execute commands.
Index ¶
- func Exec(ctx context.Context, name string, args ...string) error
- func IsRunning(pid int) bool
- func KillProcess(pid int) error
- func LookPath(file string) (string, error)
- func ParseVersionFromBinary(ctx context.Context, path string) (version.Version, error)
- func ParseVersionFromImage(ctx context.Context, runtime string, image string, command string) (version.Version, error)
- func WithAllWriteTo(ctx context.Context, w io.Writer) context.Context
- func WithAllWriteToErrOut(ctx context.Context) context.Context
- func WithDir(ctx context.Context, dir string) context.Context
- func WithEnv(ctx context.Context, env []string) context.Context
- func WithFork(ctx context.Context, fork bool) context.Context
- func WithIOStreams(ctx context.Context, streams IOStreams) context.Context
- func WithPipeStdin(ctx context.Context, pipeStdin bool) context.Context
- func WithReadFrom(ctx context.Context, r io.Reader) context.Context
- func WithReadWriter(ctx context.Context, rw io.ReadWriter) context.Context
- func WithStdIO(ctx context.Context) context.Context
- func WithUser(ctx context.Context, uid, gid *int64) context.Context
- func WithWriteTo(ctx context.Context, w io.Writer) context.Context
- type Cmd
- type IOStreams
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KillProcess ¶ added in v0.4.0
KillProcess kills the process with the given pid.
func ParseVersionFromBinary ¶ added in v0.4.0
ParseVersionFromBinary parses the version from the binary.
func ParseVersionFromImage ¶ added in v0.4.0
func ParseVersionFromImage(ctx context.Context, runtime string, image string, command string) (version.Version, error)
ParseVersionFromImage parses the version from the image.
func WithAllWriteTo ¶ added in v0.2.0
WithAllWriteTo returns a context with the given io.Writer as the In, Out, and ErrOut streams.
func WithAllWriteToErrOut ¶ added in v0.2.0
WithAllWriteToErrOut returns a context with the given io.Writer as the ErrOut stream.
func WithIOStreams ¶ added in v0.2.0
WithIOStreams returns a context with the given IOStreams.
func WithPipeStdin ¶ added in v0.2.0
WithPipeStdin returns a context with the given pipeStdin option.
func WithReadFrom ¶ added in v0.5.0
WithReadFrom returns a context with the given io.Reader as the In stream.
func WithReadWriter ¶ added in v0.2.0
WithReadWriter returns a context with the given io.ReadWriter as the In and Out streams.
Types ¶
type IOStreams ¶
type IOStreams struct { // In think, os.Stdin In io.Reader // Out think, os.Stdout Out io.Writer // ErrOut think, os.Stderr ErrOut io.Writer }
IOStreams contains the standard streams.
type Options ¶ added in v0.4.0
type Options struct { // Dir is the working directory of the command. Dir string // Env is the environment variables of the command. Env []string // UID is the user id of the command UID *int64 // GID is the group id of the command GID *int64 // IOStreams contains the standard streams. IOStreams // PipeStdin is true if the command's stdin should be piped. PipeStdin bool // Fork is true if the command should be forked. Fork bool }
Options is the options for executing a command.
func GetExecOptions ¶ added in v0.4.0
GetExecOptions returns the ExecOptions for the given context.