Documentation ¶
Index ¶
- func ExecCmd(containerID string, cmd []string) (string, error)
- func NewNetwork(name string) (testcontainers.Network, error)
- func RandomSuffix() string
- type BaseContainer
- func (bc *BaseContainer) ExecCmd(ctx context.Context, cmd []string) (int, error)
- func (bc *BaseContainer) ExposedPorts(ports []string) *BaseContainer
- func (bc *BaseContainer) GetANetworkAlias(network string) string
- func (bc *BaseContainer) GetContainerID() string
- func (bc *BaseContainer) MappedPort(ctx context.Context, port string) (nat.Port, error)
- func (bc *BaseContainer) Start(ctx context.Context) error
- func (bc *BaseContainer) Stop(ctx context.Context) error
- func (bc *BaseContainer) WaitForHTTPPath(path string) *BaseContainer
- func (bc *BaseContainer) WaitForLog(log string) *BaseContainer
- func (bc *BaseContainer) WaitForPort(port string) *BaseContainer
- func (bc *BaseContainer) WithCmd(cmd []string) *BaseContainer
- func (bc *BaseContainer) WithEnv(env map[string]string) *BaseContainer
- func (bc *BaseContainer) WithNetwork(network []string) *BaseContainer
- func (bc *BaseContainer) WithNetworkAliases(aliases map[string][]string) *BaseContainer
- type Cluster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNetwork ¶
NewNetwork creates a network.
func RandomSuffix ¶
func RandomSuffix() string
Types ¶
type BaseContainer ¶
type BaseContainer struct {
// contains filtered or unexported fields
}
BaseContainer provide the basic operations for a container.
func NewContainer ¶
func NewContainer(image string) *BaseContainer
NewContainer creates a container using the image.
func (*BaseContainer) ExposedPorts ¶
func (bc *BaseContainer) ExposedPorts(ports []string) *BaseContainer
ExposedPorts exposes the ports from the container.
func (*BaseContainer) GetANetworkAlias ¶
func (bc *BaseContainer) GetANetworkAlias(network string) string
GetANetworkAlias returns a network alias of the container.
func (*BaseContainer) GetContainerID ¶
func (bc *BaseContainer) GetContainerID() string
GetContainerID gets the container ID.
func (*BaseContainer) MappedPort ¶
MappedPort gets the outside port.
func (*BaseContainer) Start ¶
func (bc *BaseContainer) Start(ctx context.Context) error
Start starts the container.
func (*BaseContainer) Stop ¶
func (bc *BaseContainer) Stop(ctx context.Context) error
Stop stops the container.
func (*BaseContainer) WaitForHTTPPath ¶
func (bc *BaseContainer) WaitForHTTPPath(path string) *BaseContainer
WaitForHTTPPath waits for the path can be used. The Default access port is 80. TODO: support the specified path with a port.
func (*BaseContainer) WaitForLog ¶
func (bc *BaseContainer) WaitForLog(log string) *BaseContainer
WaitForLog waits for the log string appear.
func (*BaseContainer) WaitForPort ¶
func (bc *BaseContainer) WaitForPort(port string) *BaseContainer
WaitForPort waits for the container ports exposed.
func (*BaseContainer) WithCmd ¶
func (bc *BaseContainer) WithCmd(cmd []string) *BaseContainer
WithCmd sets the containers start up commands.
func (*BaseContainer) WithEnv ¶
func (bc *BaseContainer) WithEnv(env map[string]string) *BaseContainer
WithEnv sets the environment variable to the container.
func (*BaseContainer) WithNetwork ¶
func (bc *BaseContainer) WithNetwork(network []string) *BaseContainer
WithNetwork uses a existent network for the container.
func (*BaseContainer) WithNetworkAliases ¶
func (bc *BaseContainer) WithNetworkAliases(aliases map[string][]string) *BaseContainer
WithNetworkAliases creates some aliases for the container.
type Cluster ¶
type Cluster interface { // Start a cluster. Start(ctx context.Context) error // Stop a cluster. Stop(ctx context.Context) error // GetPlainTextServiceURL gets the service connect string. GetPlainTextServiceURL(ctx context.Context) (string, error) // GetHTTPServiceURL gets the HTTP service connect string. GetHTTPServiceURL(ctx context.Context) (string, error) // Close closes the resources used for starting cluster. Close(ctx context.Context) }