connection

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: GPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package connection provides implementation of the abstraction.CmdConnection interface for command tasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileConnection

func CompileConnection(conn *config.TaskConnection, logger *logrus.Entry) abstraction.CmdConnection

CompileConnection compiles the task connection based on the provided configuration and logger. It returns an abstraction.CmdConnection interface based on the type of connection specified in the configuration. If the connection type is not recognized or invalid, it logs a fatal error and returns nil.

func NewDockerAttachConnection

func NewDockerAttachConnection(log *logrus.Entry, conn *config.TaskConnection) abstraction.CmdConnection

NewDockerAttachConnection creates a new DockerAttachConnection instance. It initializes the connection configuration and logging fields. Parameters: - log: A logrus.Entry instance for logging purposes. - conn: A TaskConnection instance containing the connection configuration. Returns: - A new instance of DockerAttachConnection implementing the CmdConnection interface.

func NewDockerCreateConnection

func NewDockerCreateConnection(log *logrus.Entry, conn *config.TaskConnection) abstraction.CmdConnection

NewDockerCreateConnection initializes a new DockerCreateConnection instance. Parameters: - log: A logrus.Entry instance for logging. - conn: A TaskConnection instance containing the connection configuration. Returns: - A new instance of DockerCreateConnection.

func NewLocalCMDConn

func NewLocalCMDConn(log *logrus.Entry) abstraction.CmdConnection

NewLocalCMDConn creates a new instance of Local command connection.

Types

type DockerAttachConnection

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

func (*DockerAttachConnection) Connect

func (d *DockerAttachConnection) Connect() error

Connect establishes a connection to the Docker daemon. It initializes the Docker client with the specified connection settings. Returns: - An error if the connection fails, otherwise nil.

func (*DockerAttachConnection) Disconnect

func (d *DockerAttachConnection) Disconnect() error

Disconnect closes the connection to the Docker daemon. Returns: - An error if the disconnection fails, otherwise nil.

func (*DockerAttachConnection) Execute

func (d *DockerAttachConnection) Execute() ([]byte, error)

Execute runs the command in the Docker container and captures the output. It creates an exec instance, attaches to it, and reads the command output. Returns: - A byte slice containing the command output. - An error if the execution fails, otherwise nil.

func (*DockerAttachConnection) Prepare

func (d *DockerAttachConnection) Prepare(ctx context.Context, task *config.Task) error

Prepare sets up the DockerAttachConnection for executing a task. It reshapes the environment variables, sets the context, and creates an exec configuration. Parameters: - ctx: A context.Context instance for managing the request lifetime. - task: A Task instance containing the task configuration. Returns: - An error if the preparation fails, otherwise nil.

type DockerCreateConnection

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

DockerCreateConnection is a struct that manages the creation and execution of Docker containers.

func (*DockerCreateConnection) Connect

func (d *DockerCreateConnection) Connect() error

Connect establishes a connection to the Docker daemon. Returns: - An error if the connection fails, otherwise nil.

func (*DockerCreateConnection) Disconnect

func (d *DockerCreateConnection) Disconnect() error

Disconnect closes the connection to the Docker daemon. Returns: - An error if the disconnection fails, otherwise nil.

func (*DockerCreateConnection) Execute

func (d *DockerCreateConnection) Execute() ([]byte, error)

Execute creates, starts, and logs the output of the Docker container. Returns: - A byte slice containing the command output. - An error if the execution fails, otherwise nil.

func (*DockerCreateConnection) Prepare

func (d *DockerCreateConnection) Prepare(ctx context.Context, task *config.Task) error

Prepare sets up the Docker container configuration based on the provided task. Parameters: - ctx: A context.Context instance for managing the lifecycle of the container. - task: A Task instance containing the task configuration. Returns: - An error if the preparation fails, otherwise nil.

type Local

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

Local represents a local command connection.

func (*Local) Connect

func (l *Local) Connect() error

Connect establishes the command connection. It returns an error if the connection cannot be established.

func (*Local) Disconnect

func (l *Local) Disconnect() error

Disconnect closes the command connection. It returns an error if the disconnection process fails.

func (*Local) Execute

func (l *Local) Execute() ([]byte, error)

Execute executes the command and returns the output. It captures the command's standard output and standard error. It returns the output and an error, if any.

func (*Local) Prepare

func (l *Local) Prepare(ctx context.Context, task *config.Task) error

Prepare prepares the command for execution. It sets up the command with the provided context, task, and environment. It returns an error if the preparation fails.

Directories

Path Synopsis
Package cmdutils contain helper methods for cmd executors
Package cmdutils contain helper methods for cmd executors

Jump to

Keyboard shortcuts

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