testcontainer

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const IsSkipReaperImage = false // not skip usage reaper image on CI

IsSkipReaperImage - is skip usage Reaper Image.

View Source
const NoUseAuth = ""

NoUseAuth - not used any docker auth.

View Source
const ReaperImage = "" // use standard Reaper Image.

ReaperImage - is very important to re-define because by default testcontainers lib use reaper image based on docker.io -> https://github.com/testcontainers/testcontainers-go/blob/6ba6e7a0e4b0046507c28e24946d595a65a96dbf/reaper.go#L24

View Source
const RegistryTokenEnv = "" // not use any docker registry token for docker demon.

RegistryTokenEnv - env with docker registry token from dp.

Variables

View Source
var (
	GenericContainer = testcontainers.GenericContainer
	GenericNetwork   = testcontainers.GenericNetwork

	Mounts    = testcontainers.Mounts
	BindMount = testcontainers.BindMount
)

Func aliasing - for reduce code line size. Remove external deps from other places too.

Functions

func DoubledPort added in v1.7.2

func DoubledPort(port string) string

DoubledPort - helper func for prepare port mapping.

func GetAbsPath added in v1.7.2

func GetAbsPath(relativePath string) string

GetAbsPath - get absolute path based on pwd and relative path.

func GetAuthRegistryCredStr added in v1.6.9

func GetAuthRegistryCredStr() string

GetAuthRegistryCredStr - return auth encoded string for docker registry.

func NewCQLSHContainer

func NewCQLSHContainer(
	ctx context.Context,
	cfg CassandraConfig,
	dockerNetwork *testcontainers.DockerNetwork,
	cassandraHost string,
	cassandraPort string,
) (testcontainers.Container, error)

NewCQLSHContainer - create docker container with cql sh (for before migration query script set up).

func NewCassandraContainer

func NewCassandraContainer(
	ctx context.Context,
	cfg CassandraConfig,
	dockerNetwork *testcontainers.DockerNetwork,
) (testcontainers.Container, error)

NewCassandraContainer - create cassandra container, but do not start it yet.

func NewMigrationsContainer

func NewMigrationsContainer(
	ctx context.Context,
	cfg CassandraConfig,
	dockerNetwork *testcontainers.DockerNetwork,
	cassandraHost string,
	cassandraPort string,
) (testcontainers.Container, error)

NewMigrationsContainer - create docker container for migrations.

func PullDockerImage

func PullDockerImage(ctx context.Context, imageName string) error

PullDockerImage - pull docker image via docker client.

func TerminateIfNotNil added in v1.6.9

func TerminateIfNotNil(ctx context.Context, container Terminated) error

Types

type BaseContainerConfig

type BaseContainerConfig struct {
	Name               string // Hostname, ContainerName, Network alias
	Image              string
	Port               string
	Files              []ContainerFile
	Binds              []string
	Envs               map[string]string
	Cmd                []string
	ExposedPorts       []string
	AutoRemove         bool
	WaitingForStrategy wait.Strategy
}

BaseContainerConfig - base container request config.

type CassandraCluster

type CassandraCluster struct {
	// contains filtered or unexported fields
}

CassandraCluster - cassandra cluster struct.

func NewCassandraCluster

func NewCassandraCluster(
	ctx context.Context,
	cfg CassandraConfig,
	dockerNetwork *testcontainers.DockerNetwork,
) (*CassandraCluster, error)

NewCassandraCluster -create new CassandraCluster.

func (*CassandraCluster) Start

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

Start - start cassandra cluster with necessary migrations.

func (*CassandraCluster) Terminate

func (c *CassandraCluster) Terminate(ctx context.Context) error

Terminate - terminate container with cassandra.

type CassandraConfig

type CassandraConfig struct {
	BaseContainerConfig

	ContainerWarmUpTimeout  time.Duration
	BeforeMigrationsTimeout time.Duration
	AfterMigrationsTimeout  time.Duration

	CqlshImage             string
	PathToCqlshQueryScript string

	MigrationImage      string
	PathToMigrationsDir string
}

CassandraConfig - cassandra container config.

type Container added in v1.6.9

type Container = testcontainers.Container

Type Aliasing for reduce code line size. Remove external deps from other places too.

func NewGenericContainer added in v1.6.9

func NewGenericContainer(ctx context.Context, cfg BaseContainerConfig, dockerNetwork *DockerNetwork) (Container, error)

NewGenericContainer - create new generic container with BaseContainerConfig and DockerNetwork.

func NewKafkaContainer

func NewKafkaContainer(
	ctx context.Context,
	cfg KafkaConfig,
	dockerNetwork *DockerNetwork,
) (Container, error)

NewKafkaContainer - create new kafka container, but do not start it yet.

func NewNginxContainer

func NewNginxContainer(
	ctx context.Context,
	cfg NginxConfig,
	dockerNetwork *testcontainers.DockerNetwork,
) (Container, error)

NewNginxContainer - create nginx container, but do not start it yet.

func NewPostgresContainer

func NewPostgresContainer(
	ctx context.Context,
	cfg PostgresConfig,
	dockerNetwork *DockerNetwork,
) (Container, error)

NewPostgresContainer - create postgres container, but do not start it yet.

func NewRedisContainer

func NewRedisContainer(
	ctx context.Context,
	cfg NginxConfig,
	dockerNetwork *testcontainers.DockerNetwork,
) (Container, error)

NewRedisContainer - create redis container, but do not start it yet.

func NewZookeeperContainer

func NewZookeeperContainer(
	ctx context.Context,
	cfg ZookeeperConfig,
	dockerNetwork *DockerNetwork,
) (Container, error)

NewZookeeperContainer - create zookeeper container, but do not start it yet.

type ContainerFile added in v1.6.9

type ContainerFile = testcontainers.ContainerFile

Type Aliasing for reduce code line size. Remove external deps from other places too.

type ContainerRequest added in v1.6.9

type ContainerRequest = testcontainers.ContainerRequest

Type Aliasing for reduce code line size. Remove external deps from other places too.

func GetBaseContainerRequest

func GetBaseContainerRequest(
	cfg BaseContainerConfig,
	dockerNetwork *DockerNetwork,
) ContainerRequest

GetBaseContainerRequest - return base ContainerRequest.

type DockerNetwork added in v1.6.9

type DockerNetwork = testcontainers.DockerNetwork

Type Aliasing for reduce code line size. Remove external deps from other places too.

type GenericContainerRequest added in v1.6.9

type GenericContainerRequest = testcontainers.GenericContainerRequest

Type Aliasing for reduce code line size. Remove external deps from other places too.

type GenericNetworkRequest added in v1.6.9

type GenericNetworkRequest = testcontainers.GenericNetworkRequest

Type Aliasing for reduce code line size. Remove external deps from other places too.

type KafkaCluster

type KafkaCluster struct {
	KafkaContainer     Container
	ZookeeperContainer Container

	KafkaURI string
	// contains filtered or unexported fields
}

KafkaCluster - kafka cluster struct (together kafka container and zookeeper).

func NewKafkaCluster

func NewKafkaCluster(
	ctx context.Context,
	kafkaCfg KafkaConfig,
	zooCfg ZookeeperConfig,
	dockerNetwork *DockerNetwork,
) (*KafkaCluster, error)

NewKafkaCluster - create new kafka cluster (together kafka container + zookeeper), but do not start it yet.

func (*KafkaCluster) Start

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

Start - start ZookeeperContainer and KafkaContainer.

func (*KafkaCluster) Terminate

func (c *KafkaCluster) Terminate(ctx context.Context) error

Terminate - terminate ZookeeperContainer and KafkaContainer.

type KafkaConfig

type KafkaConfig struct {
	ClientPort string
	BrokerPort string
	BaseContainerConfig
}

KafkaConfig - kafka container config with zookeeper.

type Network added in v1.6.9

type Network = testcontainers.Network

Type Aliasing for reduce code line size. Remove external deps from other places too.

func NewDockerNetwork

func NewDockerNetwork(ctx context.Context, name string) (Network, error)

NewDockerNetwork - create new docker network.

type NetworkRequest added in v1.6.9

type NetworkRequest = testcontainers.NetworkRequest

Type Aliasing for reduce code line size. Remove external deps from other places too.

type NginxConfig

type NginxConfig struct {
	BaseContainerConfig
}

NginxConfig - nginx container config.

type PostgresConfig

type PostgresConfig struct {
	BaseContainerConfig
}

PostgresConfig - postgres container config.

type RedisConfig

type RedisConfig struct {
	BaseContainerConfig
}

RedisConfig - redis container config.

type Terminated added in v1.6.9

type Terminated interface {
	Terminate(ctx context.Context) error
}

type ZookeeperConfig

type ZookeeperConfig struct {
	BaseContainerConfig
}

ZookeeperConfig - zookeeper container config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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