# README
dockertestx
This package is an abstraction of several dockerized data storages using ory/dockertest
to bootstrap a specific dockerized instance.
Example postgres
// create postgres instance
pgDocker, err := dockertest.CreatePostgres(
dockertest.PostgresWithDetail(
pgUser, pgPass, pgDBName,
),
)
// get connection string
connString := pgDocker.GetExternalConnString()
// purge docker
if err := pgDocker.GetPool().Purge(pgDocker.GetResouce()); err != nil {
return fmt.Errorf("could not purge resource: %w", err)
}
Example spice db
- bootsrap spice db with postgres and wire them internally via network bridge
// create custom pool
pool, err := dockertest.NewPool("")
if err != nil {
return nil, err
}
// create a bridge network for testing
network, err = pool.Client.CreateNetwork(docker.CreateNetworkOptions{
Name: fmt.Sprintf("bridge-%s", uuid.New().String()),
})
if err != nil {
return nil, err
}
// create postgres instance
pgDocker, err := dockertest.CreatePostgres(
dockertest.PostgresWithDockerPool(pool),
dockertest.PostgresWithDockertestNetwork(network),
dockertest.PostgresWithDetail(
pgUser, pgPass, pgDBName,
),
)
// get connection string
connString := pgDocker.GetInternalConnString()
// create spice db instance
spiceDocker, err := dockertest.CreateSpiceDB(connString,
dockertest.SpiceDBWithDockerPool(pool),
dockertest.SpiceDBWithDockertestNetwork(network),
)
if err := dockertest.MigrateSpiceDB(connString,
dockertest.MigrateSpiceDBWithDockerPool(pool),
dockertest.MigrateSpiceDBWithDockertestNetwork(network),
); err != nil {
return err
}
// purge docker resources
if err := pool.Purge(spiceDocker.GetResouce()); err != nil {
return fmt.Errorf("could not purge resource: %w", err)
}
if err := pool.Purge(pgDocker.GetResouce()); err != nil {
return fmt.Errorf("could not purge resource: %w", err)
}
# Functions
CortexWithAlertmanagerURL is an option to assign alertmanager url.
CortexWithDockerPool is an option to assign docker pool.
CortexWithDockertestNetwork is an option to assign docker network.
CortexWithModule is an option to assign cortex module name e.g.
CortexWithS3Endpoint is an option to assign external s3/minio storage.
CortexWithDockertestNetwork is an option to assign version tag of a `quay.io/cortexproject/cortex` image.
CreateCortex is a function to create a dockerized single-process cortex with s3/minio as the backend storage.
CreateMinio creates a minio instance with default configurations.
CreateNginx is a function to create a dockerized nginx.
CreatePostgres creates a postgres instance with default configurations.
CreateSpiceDB creates a spicedb instance with postgres backend and default configurations.
No description provided by the author
MigrateMinio does migration of a `bucketName` to a minio located in `minioHost`.
MigrateMinioWithDockerPool is an option to assign docker pool.
MigrateMinioWithDockertestNetwork is an option to assign docker network.
MigrateMinioWithVersionTag is an option to assign version tag of a `minio/mc` image.
MigrateSpiceDB migrates spicedb with postgres backend.
MigrateSpiceDBWithDockerPool is an option to assign docker pool.
MigrateSpiceDBWithDockertestNetwork is an option to assign docker network.
MigrateSpiceDBWithVersionTag is an option to assign version tag of a `quay.io/authzed/spicedb` image.
MinioWithDockerPool is an option to assign docker pool.
MinioWithDockertestNetwork is an option to assign docker network.
MinioWithVersionTag is an option to assign version tag of a `quay.io/minio/minio` image.
No description provided by the author
NginxWithDockerPool is an option to assign docker pool.
NginxWithDockertestNetwork is an option to assign docker network.
NginxWithDockerPool is an option to assign docker pool.
NginxWithHealthEndpoint is an option to assign health endpoint.
No description provided by the author
NginxWithVersionTag is an option to assign version tag of a `nginx` image.
PostgresWithDetail is an option to assign custom details like username, password, and database name.
PostgresWithDockerPool is an option to assign docker pool.
PostgresWithDockertestNetwork is an option to assign docker network.
PostgresWithDockertestResourceExpiry is an option to assign docker resource expiry time.
No description provided by the author
PostgresWithVersionTag is an option to assign version tag of a `postgres` image.
SpiceDBWithDockerPool is an option to assign docker pool.
SpiceDBWithDockertestNetwork is an option to assign docker network.
No description provided by the author
SpiceDBWithPreSharedKey is an option to assign pre-shared-key.
SpiceDBWithVersionTag is an option to assign version tag of a `quay.io/authzed/spicedb` image.
# Variables
go:embed configs/nginx/cortex_nginx.conf.