Documentation
¶
Overview ¶
Package docker manages dbctl databases through the Docker Engine API.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Backup(ctx context.Context, id string, w io.Writer) error
- func (c *Client) Close() error
- func (c *Client) Create(ctx context.Context, opts *CreateOptions) (string, error)
- func (c *Client) Delete(ctx context.Context, id string, opts DeleteOptions) ([]string, error)
- func (c *Client) ImageExists(ctx context.Context, ref string) (bool, error)
- func (c *Client) Inspect(ctx context.Context, id string) (*Database, error)
- func (c *Client) List(ctx context.Context) ([]Database, error)
- func (c *Client) Logs(ctx context.Context, id string, opts LogsOptions) error
- func (c *Client) Pull(ctx context.Context, ref string) error
- func (c *Client) Restart(ctx context.Context, id string) error
- func (c *Client) Restore(ctx context.Context, id string, r io.Reader) error
- func (c *Client) Shell(ctx context.Context, id string, opts ShellOptions) error
- func (c *Client) Start(ctx context.Context, id string) error
- func (c *Client) Stats(ctx context.Context, id string) (Stats, error)
- func (c *Client) Stop(ctx context.Context, id string) error
- func (c *Client) WaitReady(ctx context.Context, id string) error
- type CreateOptions
- type Database
- type DeleteOptions
- type ExitError
- type LogsOptions
- type Port
- type ShellOptions
- type Stats
- type Volume
Constants ¶
const ContainerPrefix = "dbctl."
ContainerPrefix prefixes the name of every container managed by dbctl.
Variables ¶
var ( ErrNotFound = errors.New("database not found") ErrNotManaged = errors.New("container is not managed by dbctl") ErrNotRunning = errors.New("database is not running") ErrUnhealthy = errors.New("database is unhealthy") ErrDaemonUnreachable = errors.New("cannot reach the docker daemon") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Docker daemon on behalf of dbctl.
func New ¶
New connects to the Docker daemon from the environment and ensures the dbctl network exists.
func (*Client) Create ¶
Create creates and starts a database container with its data volume and returns the container ID.
func (*Client) Delete ¶
Delete stops and removes a database container and, unless KeepVolumes is set, its data volumes. It returns the names of the removed volumes.
func (*Client) ImageExists ¶
ImageExists reports whether the image is available locally.
func (*Client) Inspect ¶
Inspect returns the database with the given short name, container name or ID prefix.
func (*Client) Shell ¶
Shell opens the database client, or /bin/sh when the template has none or Plain is set.
type CreateOptions ¶
type CreateOptions struct {
Definition *database.Definition
Image string
Name string
Password string
HostIP string
HostPort int
}
CreateOptions configures a new database container.
type Database ¶
type Database struct {
Created time.Time
Labels map[string]string
Env map[string]string
ID string
Name string
Image string
State string
Status string
Health string
Type string
// Password is empty for databases created before dbctl stored it.
Password string
Ports []Port
Volumes []Volume
Running bool
}
Database is a container managed by dbctl.
type DeleteOptions ¶
type DeleteOptions struct {
KeepVolumes bool
}
DeleteOptions configures how a database is deleted.
type ExitError ¶
type ExitError struct {
Code int
}
ExitError reports a non-zero exit code from a command run inside a database container.
type LogsOptions ¶
LogsOptions configures where and how database logs are streamed.
type ShellOptions ¶
type ShellOptions struct {
Stdin *os.File
Stdout io.Writer
// Plain opens /bin/sh instead of the database client.
Plain bool
}
ShellOptions configures an interactive session inside a database container.
type Stats ¶
Stats is a resource usage snapshot of a database container.
func (Stats) MemoryLimitMB ¶
MemoryLimitMB returns the memory limit in megabytes.
func (Stats) MemoryUsageMB ¶
MemoryUsageMB returns the memory usage in megabytes.