docker

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCapture added in v0.13.4

func ExecCapture(ctx context.Context, cli *DockerClient, container, workingDir string, cmd []string) (string, error)

ExecCapture runs a command in a container and returns its stdout. stderr is used as the error detail when the command exits non-zero. workingDir may be empty to use the container's default.

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)

func TrimContainerName added in v0.13.3

func TrimContainerName(names []string) string

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 GetDockerCliWithSSH added in v0.12.0

func GetDockerCliWithSSH(activeCtx *config.Context, sshConn *ssh.Client, ownsSSH bool) (*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) GetContainerNameContext added in v0.12.0

func (d *DockerClient) GetContainerNameContext(ctx context.Context, 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

type ProjectSummary added in v0.10.0

type ProjectSummary struct {
	Running          int
	Total            int
	Healthy          int
	Stopped          int
	CPUPercent       float64
	MemoryBytes      uint64
	MemoryLimitBytes uint64
	HostLoad1        float64
	HostCPUCount     int
	DiskAvailable    uint64
	DiskTotal        uint64
	NetworkRXBytes   uint64
	NetworkTXBytes   uint64
	CollectedAt      time.Time
	Services         []ServiceSummary
	Status           string
}

func SummarizeProject added in v0.10.0

func SummarizeProject(ctxCfg *config.Context) (ProjectSummary, error)

func SummarizeProjectWithClient added in v0.10.0

func SummarizeProjectWithClient(ctx context.Context, cli DockerAPI, ctxCfg *config.Context) (ProjectSummary, error)

type ServiceSummary added in v0.10.0

type ServiceSummary struct {
	Service          string
	Name             string
	State            string
	Status           string
	Healthy          bool
	CPUPercent       float64
	MemoryBytes      uint64
	MemoryLimitBytes uint64
}

Jump to

Keyboard shortcuts

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