container

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveMQContainer

type ActiveMQContainer struct {
	*Container
	// contains filtered or unexported fields
}

ActiveMQContainer provides specialized ActiveMQ container management

func NewActiveMQ

func NewActiveMQ(name, username, password string, reuse bool) (*ActiveMQContainer, error)

NewActiveMQ creates a new ActiveMQ container

func (*ActiveMQContainer) GetBrokerURL

func (a *ActiveMQContainer) GetBrokerURL() string

GetBrokerURL returns the broker URL for client connections

func (*ActiveMQContainer) GetCredentials

func (a *ActiveMQContainer) GetCredentials() (string, string)

GetCredentials returns the username and password

func (*ActiveMQContainer) GetJMXPort

func (a *ActiveMQContainer) GetJMXPort() (string, error)

GetJMXPort returns the JMX monitoring port

func (*ActiveMQContainer) GetTCPBrokerURL

func (a *ActiveMQContainer) GetTCPBrokerURL() string

GetTCPBrokerURL returns the TCP broker URL for OpenWire connections

func (*ActiveMQContainer) GetWebConsoleURL

func (a *ActiveMQContainer) GetWebConsoleURL() string

GetWebConsoleURL returns the web console URL

func (*ActiveMQContainer) HealthCheck

func (a *ActiveMQContainer) HealthCheck() error

HealthCheck performs a comprehensive health check

func (*ActiveMQContainer) Start

func (a *ActiveMQContainer) Start(ctx context.Context) error

Start starts the ActiveMQ container and waits for it to be ready

type Config

type Config struct {
	Image        string
	Name         string
	Ports        map[string]string // container_port:host_port
	Env          []string
	Mounts       []Mount
	WaitStrategy WaitStrategy
	Reuse        bool
}

Config holds container configuration

type Container

type Container struct {
	logger.Logger
	// contains filtered or unexported fields
}

Container manages Docker containers with transparent reuse

func New

func New(config Config) (*Container, error)

New creates a new Container manager

func (*Container) Cleanup

func (c *Container) Cleanup(ctx context.Context) error

Cleanup removes the container

func (*Container) Errorf

func (c *Container) Errorf(format string, args ...interface{})

Errorf logs an error message with container name prefix

func (*Container) Exec

func (c *Container) Exec(ctx context.Context, cmd []string) (string, error)

Exec executes a command in the container

func (*Container) GetID

func (c *Container) GetID() string

GetID returns the container ID

func (*Container) GetPort

func (c *Container) GetPort(port string) (string, error)

GetPort returns the host port for a container port

func (*Container) Infof

func (c *Container) Infof(format string, args ...interface{})

Infof logs an informational message with container name prefix

func (*Container) IsRunning

func (c *Container) IsRunning(ctx context.Context) (bool, error)

IsRunning checks if the container is running

func (*Container) Logs

func (c *Container) Logs(ctx context.Context, follow bool) (io.ReadCloser, error)

Logs returns container logs

func (*Container) PrintLogsOnFailure

func (c *Container) PrintLogsOnFailure(ctx context.Context, reason string)

PrintLogsOnFailure prints container logs when startup fails

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

Start starts or reuses an existing container

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) error

Stop stops the container

type ContainerInfo

type ContainerInfo struct {
	ID     string
	Name   string
	Status string
	Ports  map[string]string
}

ContainerInfo holds information about an existing container

type ExecResult

type ExecResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

ExecResult holds the result of a container execution

type Manager

type Manager interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Logs(ctx context.Context, follow bool) (io.ReadCloser, error)
	Exec(ctx context.Context, cmd []string) (string, error)
	IsRunning(ctx context.Context) (bool, error)
	GetPort(port string) (string, error)
	GetID() string
	Cleanup(ctx context.Context) error
}

Manager provides container management capabilities

type Mount

type Mount struct {
	Source   string // Host path or volume name
	Target   string // Container path
	Type     string // "bind" or "volume"
	ReadOnly bool
}

Mount represents a volume mount

type SQLServerContainer

type SQLServerContainer struct {
	*Container
	// contains filtered or unexported fields
}

SQLServerContainer provides specialized SQL Server container management

func NewSQLServer

func NewSQLServer(name, password string, reuse bool) (*SQLServerContainer, error)

NewSQLServer creates a new SQL Server container

func (*SQLServerContainer) GetConnectionString

func (s *SQLServerContainer) GetConnectionString() string

GetConnectionString returns the JDBC connection string

func (*SQLServerContainer) HealthCheck

func (s *SQLServerContainer) HealthCheck() error

HealthCheck performs a comprehensive health check

func (*SQLServerContainer) Start

func (s *SQLServerContainer) Start(ctx context.Context) error

Start starts the SQL Server container and waits for it to be ready

type WaitStrategy

type WaitStrategy struct {
	Port     string
	LogMatch string
	Timeout  string
}

WaitStrategy defines how to wait for container readiness

Jump to

Keyboard shortcuts

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