Documentation
¶
Index ¶
- type Config
- func FromURL(u *url.URL) (*Config, error)
- func MariaDB(version string, opts ...ConfigOption) (*Config, error)
- func MySQL(version string, opts ...ConfigOption) (*Config, error)
- func NewConfig(opts ...ConfigOption) (*Config, error)
- func PostgreSQL(version string, opts ...ConfigOption) (*Config, error)
- type ConfigOption
- type Container
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Image is the name of the image to pull and run. Image string // Env vars to pass to the docker container. Env []string // Internal Port to expose anc connect to. Port string // Database name to create and connect on init. Database string // Out is a custom writer to send docker cli output to. Out io.Writer // contains filtered or unexported fields }
Config is used to configure container creation.
func MariaDB ¶
func MariaDB(version string, opts ...ConfigOption) (*Config, error)
MariaDB returns a new Config for a MariaDB image.
func MySQL ¶
func MySQL(version string, opts ...ConfigOption) (*Config, error)
MySQL returns a new Config for a MySQL image.
func NewConfig ¶
func NewConfig(opts ...ConfigOption) (*Config, error)
NewConfig returns a new config with the given options applied.
func PostgreSQL ¶
func PostgreSQL(version string, opts ...ConfigOption) (*Config, error)
PostgreSQL returns a new Config for a PostgreSQL image.
type ConfigOption ¶
ConfigOption allows configuring Config with functional arguments.
func Database ¶
func Database(name string) ConfigOption
Database sets the database name to connect to. For example:
func Env ¶
func Env(env ...string) ConfigOption
Env sets the environment variables to pass to the container. For example:
Config(Image("mysql"), Env("MYSQL_ROOT_PASSWORD=password")) Config(Image("postgres"), Env("MYSQL_ROOT_PASSWORD=password"))
func Image ¶
func Image(i string) ConfigOption
Image sets the docker image to use. For example:
Image("mysql") Image("postgres:13")
func Out ¶
func Out(w io.Writer) ConfigOption
Out sets an io.Writer to use when running docker commands. For example:
buf := new(bytes.Buffer) NewConfig(Out(buf))
func Port ¶
func Port(p string) ConfigOption
Port sets the port the container services exposes. For example:
Port("3306") Port("5432")
type Container ¶
type Container struct { // ID of the container. ID string // Passphrase of the root user. Passphrase string // Port on the host this containers service is bound to. Port string // contains filtered or unexported fields }
A Container is an instance of a created container.