Documentation
¶
Index ¶
- func Close() error
- func ContainerExists(containerID string) bool
- func CreateContainer(...) (string, error)
- func CreateUser(...) error
- func DeleteUser(containerID, dbType, adminUser, adminPassword, username, dbName string) error
- func ExecCommand(containerID string, cmd []string) (string, error)
- func ExecCommandStdin(containerID string, cmd []string, stdin []byte) (string, error)
- func FindAvailablePort(startPort string) (string, error)
- func GetActualVersion(containerID, dbType string) (string, error)
- func GetConfigFileName(dbType string) string
- func Initialize() error
- func IsPortAvailable(port string) (bool, error)
- func Ping(ctx context.Context) error
- func RemoveContainer(containerID string) error
- func RemoveVolume(volumeType, volumePath string) error
- func RestartContainer(containerID string) error
- func RotatePassword(...) error
- func StartContainer(containerID string) error
- func StopContainer(containerID string) error
- type DBConfig
- type ManagedContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerExists ¶
ContainerExists checks if a container exists
func CreateContainer ¶
func CreateContainer(dbType, displayName, username, password, port, volumeType, volumePath, version string) (string, error)
CreateContainer creates and starts a database container
func CreateUser ¶
func CreateUser(containerID, dbType, adminUser, adminPassword, username, password, dbName string) error
CreateUser creates a new user in the database. admin* are the privileged credentials used to authenticate the operation.
func DeleteUser ¶
DeleteUser deletes a user from the database.
func ExecCommand ¶
ExecCommand runs a command in a container and returns its combined, demultiplexed stdout/stderr output.
func ExecCommandStdin ¶ added in v0.5.0
ExecCommandStdin runs a command in a container, writing stdin to it, and returns the combined, demultiplexed stdout/stderr output. It is used to feed schema/seed scripts to a database client (e.g. psql, mysql).
func FindAvailablePort ¶
FindAvailablePort finds the next available port starting from startPort.
func GetActualVersion ¶
GetActualVersion retrieves the actual database version from a running container
func GetConfigFileName ¶
GetConfigFileName returns the main config file name for the database type
func Initialize ¶
func Initialize() error
Initialize creates a Docker client. It does not contact the daemon, so commands that only read local state (version, ls, info) work while Docker is down; commands that need the daemon surface a clear error on first use.
func IsPortAvailable ¶
IsPortAvailable reports whether a TCP port can be bound on the host. This catches both Docker-published ports and any other local process.
func RemoveContainer ¶
RemoveContainer removes a container
func RemoveVolume ¶
RemoveVolume removes the on-disk data for a container's volume. mkdb "named" volumes are bind-mounted directories under the data dir; bind mounts point at a user-supplied path and are left untouched.
func RestartContainer ¶
RestartContainer restarts a container
func RotatePassword ¶
func RotatePassword(containerID, dbType, adminUser, adminPassword, username, newPassword, dbName string) error
RotatePassword rotates a user's password.
func StartContainer ¶
StartContainer starts an existing (stopped) container
func StopContainer ¶
StopContainer stops a container gracefully
Types ¶
type DBConfig ¶
DBConfig represents database-specific configuration
func GetDBConfig ¶
GetDBConfig returns the configuration for a database type, or an error if the type is unknown.
type ManagedContainer ¶ added in v0.5.0
type ManagedContainer struct {
ID string
Name string // mkdb display name (from the mkdb.name label)
State string // Docker state, e.g. "running", "exited"
}
ManagedContainer is a summary of a Docker container created by mkdb.
func ListManaged ¶ added in v0.5.0
func ListManaged(ctx context.Context) ([]ManagedContainer, error)
ListManaged returns all Docker containers labeled as mkdb-managed, running or not. It is used by `mkdb doctor` to detect drift between Docker and mkdb's own state.