Documentation ¶
Overview ¶
Package connection provides implementation of the abstraction.CmdConnection interface for command tasks.
Index ¶
- func CompileConnection(conn *config.TaskConnection, logger *logrus.Entry) abstraction.CmdConnection
- func NewDockerAttachConnection(log *logrus.Entry, conn *config.TaskConnection) abstraction.CmdConnection
- func NewDockerCreateConnection(log *logrus.Entry, conn *config.TaskConnection) abstraction.CmdConnection
- func NewLocalCMDConn(log *logrus.Entry) abstraction.CmdConnection
- type DockerAttachConnection
- type DockerCreateConnection
- type Local
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 ¶
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 ¶
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 ¶
Connect establishes the command connection. It returns an error if the connection cannot be established.
func (*Local) Disconnect ¶
Disconnect closes the command connection. It returns an error if the disconnection process fails.