Documentation
¶
Overview ¶
Package command provides interfaces and implementations for executing commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DockerClient ¶
type DockerClient interface {
// ImagePull requests the docker host to pull an image from a remote registry.
//
// ctx is the context for the request.
// ref is the ref.
// options is the options.
//
// Returns the result.
// Returns an error if the operation fails.
ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
// ContainerCreate creates a new container based in the given configuration.
//
// ctx is the context for the request.
// config holds the configuration settings.
// hostConfig is the hostConfig.
// networkingConfig is the networkingConfig.
// platform is the platform.
// containerName is the containerName.
//
// Returns the response.
// Returns an error if the operation fails.
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.CreateResponse, error)
// ContainerStart sends a request to the docker daemon to start a container.
//
// ctx is the context for the request.
// containerID is the containerID.
// options is the options.
//
// Returns an error if the operation fails.
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
// ContainerRemove kills and removes a container from the docker host.
//
// ctx is the context for the request.
// containerID is the containerID.
// options is the options.
//
// Returns an error if the operation fails.
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
// ContainerLogs returns the logs generated by a container in an io.ReadCloser.
//
// ctx is the context for the request.
// container is the container.
// options is the options.
//
// Returns the result.
// Returns an error if the operation fails.
ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error)
// ContainerWait waits until the specified container is in a certain state.
//
// ctx is the context for the request.
// containerID is the containerID.
// condition is the condition.
//
// Returns the response.
// Returns the result.
ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
// ContainerAttach attaches to a container to read its output or write input.
//
// ctx is the context for the request.
// container is the container.
// options is the options.
//
// Returns the response.
// Returns an error if the operation fails.
ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error)
// Close closes the client and releases any associated resources.
//
// Returns an error if the operation fails.
Close() error
}
DockerClient interface matching the subset of docker client methods used.
type Executor ¶
type Executor interface {
// Execute executes a command and returns the stdout and stderr as streams.
//
// Summary: Executes a command.
//
// Parameters:
// - ctx (context.Context): The context for the request.
// - command (string): The command to execute.
// - args ([]string): The arguments for the command.
// - workingDir (string): The working directory for execution.
// - env ([]string): The environment variables.
//
// Returns:
// - stdout (io.ReadCloser): The standard output stream.
// - stderr (io.ReadCloser): The standard error stream.
// - exitCode (<-chan int): A channel that receives the exit code.
// - err (error): An error if the operation fails.
Execute(ctx context.Context, command string, args []string, workingDir string, env []string) (stdout, stderr io.ReadCloser, exitCode <-chan int, err error)
// ExecuteWithStdIO executes a command and returns the stdin, stdout, and stderr as streams.
//
// Summary: Executes a command with full I/O streams.
//
// Parameters:
// - ctx (context.Context): The context for the request.
// - command (string): The command to execute.
// - args ([]string): The arguments for the command.
// - workingDir (string): The working directory for execution.
// - env ([]string): The environment variables.
//
// Returns:
// - stdin (io.WriteCloser): The standard input stream.
// - stdout (io.ReadCloser): The standard output stream.
// - stderr (io.ReadCloser): The standard error stream.
// - exitCode (<-chan int): A channel that receives the exit code.
// - err (error): An error if the operation fails.
ExecuteWithStdIO(ctx context.Context, command string, args []string, workingDir string, env []string) (stdin io.WriteCloser, stdout, stderr io.ReadCloser, exitCode <-chan int, err error)
}
Executor is an interface for executing commands.
func NewExecutor ¶
func NewExecutor(containerEnv *configv1.ContainerEnvironment) Executor
NewExecutor creates a new command executor.
Summary: Creates a new command executor (local or docker).
Parameters:
- containerEnv (*configv1.ContainerEnvironment): The container environment configuration (if any).
Returns:
- Executor: A new Executor instance.
Side Effects:
- May initialize a Docker client.
func NewLocalExecutor ¶
func NewLocalExecutor() Executor
NewLocalExecutor creates a new local command executor.
Summary: Creates a new local command executor.
Parameters:
- None.
Returns:
- Executor: A new local Executor instance.
Side Effects:
- None.
Click to show internal directories.
Click to hide internal directories.