environment

package
v0.0.0-...-ede9753 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAdminerNotInitialized = fmt.Errorf("adminer not initialized")
View Source
var ErrMinioNotInitialized = fmt.Errorf("minio  not initialized")
View Source
var ErrPostgresAdminerIsNil = fmt.Errorf("postgres: adminer is nil")
View Source
var ErrPostgresNotInitialized = fmt.Errorf("postgres  not initialized")

Functions

func InitApp

func InitApp(conf *database.Config, minioConfig MinIOConfig) (_ application.Application, err error)

initialize the application using the config provided by newly created postgres

func InitDatabase

func InitDatabase(config *database.Config) (db database.Database, err error)

initialize a database connection using the config establish connection with the database

func InitRestServer

func InitRestServer(app application.Application, apiKey []byte) (*restserver.S, error)

initialize the rest server from getting random port from the free ports

Types

type Adminer

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

func NewAdminer

func NewAdminer(opts ...AdminerOption) *Adminer

func NewAdminerStarted

func NewAdminerStarted(opts ...AdminerOption) (*Adminer, error)

NewAdminerStarted returns adminer running in a docker dontainer.

func (*Adminer) Domain

func (a *Adminer) Domain() string

Port return the random external port of the docker dontainer

func (*Adminer) IpContainer

func (a *Adminer) IpContainer() string

IpContainer returns the ip of the container in th network with `networkID`

func (*Adminer) NetworkID

func (a *Adminer) NetworkID() string

func (*Adminer) Port

func (a *Adminer) Port() int

Port return the random external port of the docker dontainer

func (*Adminer) PortContainer

func (a *Adminer) PortContainer() int

PortContainer returns port the service is listening to inside the container.

func (*Adminer) Start

func (a *Adminer) Start() (err error)

Start adminer inside a docker container. Can only be called once during the lifetime of adminer.

func (*Adminer) Stop

func (a *Adminer) Stop(removeNetwork bool) (err error)

Stop the docker container

type AdminerOption

type AdminerOption func(*Adminer)

func WithAdminerHost

func WithAdminerHost(d string) AdminerOption

func WithAdminerNetwork

func WithAdminerNetwork(networkID string) AdminerOption

WithNetwork by default adminer creates it's own random network. Pass a network id to make adminer join a existings network.

func WithFixedHostPort

func WithFixedHostPort(port string) AdminerOption

WithFixedHostPort sets a fixed host port

type MinIO

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

func NewMinio

func NewMinio() *MinIO

func NewMinioStarted

func NewMinioStarted() (*MinIO, error)

func (*MinIO) Config

func (m *MinIO) Config() MinIOConfig

Config return the config object usually passed to application inside bob

func (*MinIO) Port

func (m *MinIO) Port() int

Port returns the external port of the database

func (*MinIO) Stop

func (m *MinIO) Stop(removeNetwork bool) (err error)

Stop the docker container

type MinIOConfig

type MinIOConfig struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
	UseSSL          bool
}

type Network

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

func NewNetwork

func NewNetwork() (n *Network, err error)

func (*Network) Close

func (n *Network) Close() (err error)

func (*Network) ID

func (n *Network) ID() string

type Option

type Option func(*Postgres)

func WithCredentials

func WithCredentials(user, password string) Option

func WithDatabaseName

func WithDatabaseName(name string) Option

func WithDebug

func WithDebug(debug bool) Option

WithDebug in debug mode postgres will additionaly start a adminer container to inspect the database. It also waits at the end of the test for SIGTERM to enable database inspection.

func WithHostname

func WithHostname(hostname string) Option

func WithPostgresNetwork

func WithPostgresNetwork(networkID string) Option

WithPostgresNetwork by default postgres creates it's own random network. Pass a network id to make postgres join a existings network.

func WithTag

func WithTag(tag string) Option

type Postgres

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

func NewPostgres

func NewPostgres(opts ...Option) *Postgres

func NewPostgresStarted

func NewPostgresStarted(opts ...Option) (*Postgres, error)

NewPostgresStarted returns a postgres database running in a docker dontainer.

func (*Postgres) Config

func (p *Postgres) Config() db.Config

Config return the config object usually passed to application inside bob

func (*Postgres) DSN

func (p *Postgres) DSN() string

func (*Postgres) Database

func (p *Postgres) Database() string

func (*Postgres) DatabaseName

func (p *Postgres) DatabaseName() string

DatabaseName returns the database name

func (*Postgres) Drop

func (p *Postgres) Drop() (err error)

Drop all tables in a database. Useful for cleanup up after a test.

func (*Postgres) IpContainer

func (p *Postgres) IpContainer() string

IpContainer returns the ip of the container in th network with `networkID`

func (*Postgres) NetworkID

func (p *Postgres) NetworkID() string

func (*Postgres) Port

func (p *Postgres) Port() int

Port return the external port of of the database

func (*Postgres) PortContainer

func (p *Postgres) PortContainer() int

PortContainer returns port the service is listening to inside the container.

func (*Postgres) Start

func (p *Postgres) Start() (err error)

Start the postgres database inside a docker container. Can only be called once during the lifetime of a database.

func (*Postgres) Stop

func (p *Postgres) Stop(removeNetwork bool) (err error)

Stop the docker container

Jump to

Keyboard shortcuts

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