Documentation
¶
Overview ¶
Package dbdocker runs a one-off database container so pggen can introspect a schema without a database of its own.
It holds the parts that don't care which database is running — building an image from a Dockerfile and init scripts, starting and stopping the container, capturing its logs, picking a host port. The database-specific pieces (the image, the port it listens on, how to tell it is ready) come from Config; see internal/pgdocker and internal/chdocker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitScriptNames ¶
InitScriptNames returns the name each init script takes in the build context, numbered so the image runs them in order.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client controls a running database container.
func (*Client) GetContainerLogs ¶
GetContainerLogs returns all stdout and stderr logs for the container. Useful to enrich output when pggen fails to start the container.
type Config ¶
type Config struct {
// Name of the database, used in log and error messages.
Name string
// Dockerfile is the full contents of the Dockerfile to build. It should
// copy each entry of InitScripts, by base name, wherever the image expects
// initialization scripts.
Dockerfile string
// InitScripts are host paths to schema files, added to the build context
// under a numeric prefix so they run in the order given.
InitScripts []string
// Env is the container environment, like "POSTGRES_HOST_AUTH_METHOD=trust".
Env []string
// Cmd overrides the image command, if set.
Cmd []string
// Port the database listens on inside the container, like "5432/tcp".
Port nat.Port
// Tmpfs mounts, used to keep the data directory off disk.
Tmpfs map[string]string
// WaitReady blocks until the database accepts connections on the host port.
WaitReady func(ctx context.Context, port ports.Port) error
}
Config describes the container to run.