tools

package
v3.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package tools provides helpers to initialize data.

Index

Constants

View Source
const (

	// DefaultStopTimeout defines the default timeout for Postgres stop.
	DefaultStopTimeout = 600

	// ViewLogsCmd tells the command to view docker container logs.
	ViewLogsCmd = "docker logs --since 1m -f"
)
View Source
const (
	// DataStateAtFormat describes format of dataStateAt.
	DataStateAtFormat = "20060102150405"
)

Variables

This section is empty.

Functions

func AddVolumesToHostConfig

func AddVolumesToHostConfig(ctx context.Context, docker *client.Client, hostConfig *container.HostConfig, dataDir string) error

AddVolumesToHostConfig adds volumes to container host configuration depends on process environment.

func CheckContainerReadiness

func CheckContainerReadiness(ctx context.Context, dockerClient *client.Client, containerID string) (err error)

CheckContainerReadiness checks health and reports if container is ready.

func DetectPGVersion

func DetectPGVersion(dataDir string) (float64, error)

DetectPGVersion defines PostgreSQL version of PGDATA.

func DiscoverDataStateAt

func DiscoverDataStateAt(input io.Reader) (string, error)

DiscoverDataStateAt scans input data and discovers time when the archive is created.

func ExecCommand

func ExecCommand(ctx context.Context, dockerClient *client.Client, containerID string, execCfg types.ExecConfig) error

ExecCommand runs command in Docker container.

func ExecCommandWithOutput

func ExecCommandWithOutput(ctx context.Context, dockerClient *client.Client, containerID string, execCfg types.ExecConfig) (string, error)

ExecCommandWithOutput runs command in Docker container and returns the command output.

func GeneratePassword

func GeneratePassword() (string, error)

GeneratePassword generates a new password.

func GetMountsFromMountPoints

func GetMountsFromMountPoints(dataDir string, mountPoints []types.MountPoint) []mount.Mount

GetMountsFromMountPoints creates a list of mounts.

func InitDB

func InitDB(ctx context.Context, dockerClient *client.Client, containerID string) error

InitDB stops Postgres inside container.

func IsEmptyDirectory

func IsEmptyDirectory(dir string) (bool, error)

IsEmptyDirectory checks whether a directory is empty.

func LsContainerDirectory

func LsContainerDirectory(ctx context.Context, dockerClient *client.Client, containerID, dir string) ([]string, error)

LsContainerDirectory lists content of the directory in a container.

func MakeDir

func MakeDir(ctx context.Context, dockerClient *client.Client, dumpContID, dataDir string) error

MakeDir creates a new directory inside a container.

func PrintContainerLogs

func PrintContainerLogs(ctx context.Context, dockerClient *client.Client, containerID string)

PrintContainerLogs prints container output.

func PrintLastPostgresLogs

func PrintLastPostgresLogs(ctx context.Context, dockerClient *client.Client, containerID, clonePath string)

PrintLastPostgresLogs prints Postgres container logs.

func PullImage

func PullImage(ctx context.Context, dockerClient *client.Client, image string) error

PullImage pulls a Docker image.

func RemoveContainer

func RemoveContainer(ctx context.Context, dockerClient *client.Client, containerID string, stopTimeout time.Duration)

RemoveContainer stops and removes container.

func StartPostgres

func StartPostgres(ctx context.Context, dockerClient *client.Client, containerID string, timeout int) error

StartPostgres stops Postgres inside container.

func StopContainer

func StopContainer(ctx context.Context, dockerClient *client.Client, containerID string, stopTimeout time.Duration)

StopContainer stops container.

func StopPostgres

func StopPostgres(ctx context.Context, dockerClient *client.Client, containerID, dataDir string, timeout int) error

StopPostgres stops Postgres inside container.

func TouchFile

func TouchFile(filename string) error

TouchFile creates an empty file.

func TrimPort

func TrimPort(hostname string) string

TrimPort trims a port from a hostname if the port exists.

Types

type ErrHealthCheck

type ErrHealthCheck struct {
	ExitCode int
	Output   string
}

ErrHealthCheck defines a health check errors.

func (*ErrHealthCheck) Error

func (e *ErrHealthCheck) Error() string

Error prints a health check error.

Directories

Path Synopsis
Package cont provides tools to manage service containers started by Database Lab Engine.
Package cont provides tools to manage service containers started by Database Lab Engine.
Package db provides database helpers.
Package db provides database helpers.
Package defaults contains default values.
Package defaults contains default values.
Package fs provides tools for working with the filesystem.
Package fs provides tools for working with the filesystem.
Package health provides tools to set up container health check options.
Package health provides tools to set up container health check options.
Package pgtool provides tools to run PostgreSQL-specific commands.
Package pgtool provides tools to run PostgreSQL-specific commands.

Jump to

Keyboard shortcuts

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