tools

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 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 added in v2.4.0

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

InitDB stops Postgres inside container.

func IsEmptyDirectory

func IsEmptyDirectory(dir string) (bool, error)

IsEmptyDirectory checks whether a directory is empty.

func PrintContainerLogs

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

PrintContainerLogs prints container output.

func PrintLastPostgresLogs added in v2.4.0

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 added in v2.4.0

func StartPostgres(ctx context.Context, dockerClient *client.Client, containerID, dataDir 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 added in v2.4.0

func TrimPort(hostname string) string

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

Types

type ErrHealthCheck added in v2.4.0

type ErrHealthCheck struct {
	ExitCode int
	Output   string
}

ErrHealthCheck defines a health check errors.

func (*ErrHealthCheck) Error added in v2.4.0

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 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