exec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(de *Exec, networkName string) error

Connect connects an Exec to the specified docker network.

func NewTempImage

func NewTempImage(contextDir, targetStage string, opts ...ImageOption) (string, func() error, error)

NewTempImage builds a new image of the specified context and stage then returns the tag and cleaner function.

func NewTempNetwork

func NewTempNetwork(networkName string) (func() error, error)

NewTempNetwork creates a new network and returns its cleaner function.

func Supported

func Supported() error

Supported checks if this pkg can run on the current system.

Types

type Cmd

type Cmd struct {

	// Path is the path of the command to run.
	Path string

	// Args holds the command line arguents.
	Args []string

	// Env holds the environment variables for the command.
	Env []string

	// Dir specifies the working direcotroy of the command.
	Dir string

	// Stdin specifies the stdin of the command.
	Stdin io.Reader

	// Stdout and Stderr specifies the stdout and stderr of the command.
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

Cmd is exec.Cmd-like object which provides the way to execute commands in a container.

func (*Cmd) CombinedOutput

func (cmd *Cmd) CombinedOutput() ([]byte, error)

CombinedOutput runs the specified commands and returns the combined output of stdout and stderr.

func (*Cmd) Output

func (cmd *Cmd) Output() ([]byte, error)

Output runs the specified commands and returns its stdout.

func (*Cmd) Run

func (cmd *Cmd) Run() error

Run runs the specified commands.

func (*Cmd) Start

func (cmd *Cmd) Start() error

func (*Cmd) StderrPipe

func (cmd *Cmd) StderrPipe() (io.ReadCloser, error)

StderrPipe returns the pipe that will be connected to stderr of the executed command.

func (*Cmd) StdinPipe

func (cmd *Cmd) StdinPipe() (io.WriteCloser, error)

StdinPipe returns the pipe that will be connected to stdin of the executed command.

func (*Cmd) StdoutPipe

func (cmd *Cmd) StdoutPipe() (io.ReadCloser, error)

StdoutPipe returns the pipe that will be connected to stdout of the executed command.

func (*Cmd) String

func (cmd *Cmd) String() string

String returns a human-readable description of this command.

func (*Cmd) Wait

func (cmd *Cmd) Wait() error

type Exec

type Exec struct {

	// ContainerName is the name of the target container.
	ContainerName string
}

Exec is an executing environment for a container. Commands can be executed in the container using Command method.

func New

func New(containerName string) (*Exec, error)

New creates a new Exec for the specified container.

func (Exec) Command

func (e Exec) Command(name string, arg ...string) *Cmd

Command creates a new Cmd for the specified commands.

func (Exec) Kill

func (e Exec) Kill() error

Kill kills the underlying container.

type ImageOption

type ImageOption func(o *imageOptions)

func WithPatchContextDir

func WithPatchContextDir(patchContextDir string) ImageOption

WithPatchContextDir is a context dir of a build which will be executed based on the Dockerfile specified by the arguments of NewTempImage. When this option is used, WithPatchDockerfile corresponding to this context dir must be specified as well.

func WithPatchDockerfile

func WithPatchDockerfile(patchDockerfile string) ImageOption

WithPatchDockerfile is a part of Dockerfile that will be built based on the Dockerfile specified by the arguments of NewTempImage.

func WithTempImageBuildArgs

func WithTempImageBuildArgs(buildArgs ...string) ImageOption

WithTempImageBuildArgs specifies the build args that will be used during build.

func WithTempImageStdio

func WithTempImageStdio(stdout, stderr io.Writer) ImageOption

WithTempImageStdio specifies stdio which docker build command's stdio will be streamed into.

Jump to

Keyboard shortcuts

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