docker

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigEnv

func GetConfigEnv(ctx context.Context, cli DockerAPI, containerName, envName string) (string, error)

func GetDatabaseUris added in v0.2.0

func GetDatabaseUris(c *config.Context) (string, string, error)

GetDatabaseUris constructs MySQL and SSH connection URIs for database tools like Sequel Ace Returns: mysqlURI, sshURI, error

func GetSecret

func GetSecret(ctx context.Context, cli DockerAPI, c *config.Context, containerName, secretName string) (string, error)

Types

type DockerAPI

type DockerAPI interface {
	ContainerInspect(ctx context.Context, container string) (dockercontainer.InspectResponse, error)
	ContainerList(ctx context.Context, options dockercontainer.ListOptions) ([]dockercontainer.Summary, error)
}

DockerAPI abstracts the Docker client functionality needed by our package.

type DockerClient

type DockerClient struct {
	CLI    DockerAPI
	SshCli *ssh.Client
	// contains filtered or unexported fields
}

func GetDockerCli

func GetDockerCli(activeCtx *config.Context) (*DockerClient, error)

func (*DockerClient) Close

func (d *DockerClient) Close() error

func (*DockerClient) Exec

func (d *DockerClient) Exec(ctx context.Context, opts ExecOptions) (int, error)

Exec executes a command in a container using the DockerClient

func (*DockerClient) ExecInteractive

func (d *DockerClient) ExecInteractive(ctx context.Context, containerID string, cmd []string) (int, error)

ExecInteractive executes an interactive command with TTY

func (*DockerClient) ExecSimple

func (d *DockerClient) ExecSimple(ctx context.Context, containerID string, cmd []string) (int, error)

ExecSimple executes a simple command and returns the exit code

func (*DockerClient) GetContainerName

func (d *DockerClient) GetContainerName(c *config.Context, service string) (string, error)

func (*DockerClient) GetServiceIp

func (d *DockerClient) GetServiceIp(ctx context.Context, c *config.Context, containerName string) (string, error)

type ExecOptions

type ExecOptions struct {
	// Container is the container ID or name
	Container string

	// Cmd is the command to execute
	Cmd []string

	// Env is additional environment variables
	Env []string

	// WorkingDir is the working directory
	WorkingDir string

	// User to run as
	User string

	// AttachStdin attaches stdin
	AttachStdin bool

	// AttachStdout attaches stdout
	AttachStdout bool

	// AttachStderr attaches stderr
	AttachStderr bool

	// Tty allocates a pseudo-TTY
	Tty bool

	// Stdin is the input stream
	Stdin io.Reader

	// Stdout is the output stream
	Stdout io.Writer

	// Stderr is the error stream
	Stderr io.Writer
}

ExecOptions holds options for executing a command in a container

Jump to

Keyboard shortcuts

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