services

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigVariablePwd     = "{{PWD}}"
	ConfigVariableDate    = "{{DATE}}"
	ConfigVariableUserDir = "{{USERDIR}}"
)
View Source
const (
	DockerRun                    = "docker run"
	DockerContainerList          = "docker container list"
	DockerContainerInspect       = "docker container inspect"
	DockerContainerStop          = "docker container stop"
	DockerContainerStart         = "docker container start"
	DockerContainerInspectStatus = "docker container inspect -f '{{json .State}}'"

	ContainerStatusStopped = "exited"
	ContainerStatusRunning = "running"

	ErrContainerStopTimeout  = "the requested container did not stop within the requested time frame"
	ErrContainerStartTimeout = "the requested container did not start within the requested time frame"
)
View Source
const (
	ErrFileAlreadyExists = "a file already exists with the requested path"
)

Variables

View Source
var (
	ErrDiscordContentLengthTooLong = "the message length is greater then 2000 characters"
)

Functions

func ReplaceAllConfigVariables

func ReplaceAllConfigVariables(value string) (string, error)

This function finds all the known config variables and replaces the values.

func RunCommand

func RunCommand(cmd string) (string, error)

Types

type BackupClient

type BackupClient struct {
	FileExtension string
}

func NewBackupClient

func NewBackupClient() BackupClient

func (BackupClient) BackupDockerVolume

func (c BackupClient) BackupDockerVolume(details domain.RunDetails, config domain.ContainerDocker) error

This will return the location of the new file on disk if it was successful

func (BackupClient) GetValidFileName

func (c BackupClient) GetValidFileName(config domain.ConfigContainerTar, directory string) (string, error)

This will update the filename if one already exists with a number appended

type BackupVolumeParams

type BackupVolumeParams struct {
	ContainerName  string
	BackupFolder   string
	BackupFilename string
	TargetFolder   string
}

type DiscordAlertClient

type DiscordAlertClient struct {
	// contains filtered or unexported fields
}

func NewDiscordAlertClient

func NewDiscordAlertClient(Webhooks []string, Username string) DiscordAlertClient

func (DiscordAlertClient) NewMessage

func (c DiscordAlertClient) NewMessage() domain.DiscordMessage

func (*DiscordAlertClient) ReplaceContent

func (c *DiscordAlertClient) ReplaceContent(content string)

func (DiscordAlertClient) Send

func (c DiscordAlertClient) Send() error

func (DiscordAlertClient) SendMessage

func (c DiscordAlertClient) SendMessage(msg domain.DiscordMessage) error

func (*DiscordAlertClient) SetMessage

func (c *DiscordAlertClient) SetMessage(Message domain.DiscordMessage)

func (*DiscordAlertClient) UpdateContent

func (c *DiscordAlertClient) UpdateContent(content string)

type DockerCliClient

type DockerCliClient struct{}

This client requires the docker cli to be installed.

func NewDockerCliClient

func NewDockerCliClient() DockerCliClient

func (DockerCliClient) BackupDockerVolume

func (c DockerCliClient) BackupDockerVolume(params BackupVolumeParams) (string, error)

func (DockerCliClient) InspectContainer

func (c DockerCliClient) InspectContainer(name string) (string, error)

func (DockerCliClient) InspectContainerStatus

func (c DockerCliClient) InspectContainerStatus(name string) (DockerContainerStatus, error)

func (DockerCliClient) IsRunning

func (c DockerCliClient) IsRunning(name string) bool

func (DockerCliClient) IsStopped

func (c DockerCliClient) IsStopped(name string) bool

func (DockerCliClient) ListContainers

func (c DockerCliClient) ListContainers() (string, error)

func (DockerCliClient) PollStartContainer

func (c DockerCliClient) PollStartContainer(name string) error

func (DockerCliClient) PollStopContainer

func (c DockerCliClient) PollStopContainer(name string) error

This will block the thread till the container has stopped. This will wait for a total of 60 seconds, if the container does not stop in time, we error out.

func (DockerCliClient) StartContainer

func (c DockerCliClient) StartContainer(name string) (string, error)

This sends the start command but does not wait for it to come online.

func (DockerCliClient) StopContainer

func (c DockerCliClient) StopContainer(name string) (string, error)

This sends the stop command but does not wait for it to go offline.

type DockerContainerStatus

type DockerContainerStatus struct {
	Status     string    `json:"Status"`
	Running    bool      `json:"Running"`
	Paused     bool      `json:"Paused"`
	Restarting bool      `json:"Restarting"`
	OOMKilled  bool      `json:"OOMKilled"`
	Dead       bool      `json:"Dead"`
	Pid        int       `json:"Pid"`
	ExitCode   int       `json:"ExitCode"`
	Error      string    `json:"Error"`
	StartedAt  time.Time `json:"StartedAt"`
	FinishedAt time.Time `json:"FinishedAt"`
}

type GetLocalDestValuesParam

type GetLocalDestValuesParam struct {
	Container domain.ContainerDocker
	Backup    domain.RunBackupDetails
	Dest      domain.ConfigDestLocal
}

type LocalDetailsParam

type LocalDetailsParam struct {
	Counter       int
	Container     domain.ContainerDocker
	BackupDetails domain.RunBackupDetails
	DestLocal     domain.ConfigDestLocal
}

type MoveClient

type MoveClient struct {
	// contains filtered or unexported fields
}

func NewMoveClient

func NewMoveClient(backupName, backupPath, containerName, destination string) MoveClient

func (MoveClient) CopyFile

func (c MoveClient) CopyFile(source, dest string) error

func (MoveClient) Move

func (c MoveClient) Move(details domain.RunDetails) error

type ReconClient

type ReconClient struct {
	// contains filtered or unexported fields
}

func NewReconClient

func NewReconClient(config domain.Config) ReconClient

The recon client goes and check to see what we need before any actions are taken. Once the recon has done its job all the other services will be able run without needing to validate along the way.

func (ReconClient) DockerScout

func (c ReconClient) DockerScout(container domain.ContainerDocker) (domain.RunDetails, error)

Scout is the main logic loop and reports back its findings to

func (ReconClient) GetLocalDestDetails

func (c ReconClient) GetLocalDestDetails(params LocalDetailsParam) (domain.RunDetailsDestLocal, error)

func (c ReconClient) GetLocalDestDetails(config domain.ConfigDestLocal, backup domain.RunBackupDetails) domain.RunDetailsDestLocal {

func (ReconClient) GetValidFileName

func (c ReconClient) GetValidFileName(config domain.ConfigContainerTar, directory string) string

This will update the filename if one already exists with a number appended

func (ReconClient) NewBackupDetails

func (c ReconClient) NewBackupDetails(targetDir, folderName, destDir string) (domain.RunBackupDetails, error)

This will generate new backup details and store them.

func (ReconClient) TestBackupName

func (c ReconClient) TestBackupName(dir, name, ext string) error

Test to make sure the path works before we commit the values to the RunDetails.

func (ReconClient) ValidateBackupDetails

func (c ReconClient) ValidateBackupDetails(details domain.RunBackupDetails) error

func (ReconClient) ValidateLocalDestDetails

func (c ReconClient) ValidateLocalDestDetails(details domain.RunDetailsDestLocal) error

type RetainClient

type RetainClient struct {
	// contains filtered or unexported fields
}

func NewRetainClient

func NewRetainClient(config domain.ConfigDestLocal, containerName string, retainDays int) RetainClient

func (RetainClient) Check

func (c RetainClient) Check(pattern string) error

func (RetainClient) CountFiles

func (c RetainClient) CountFiles(pattern string) (int, error)

func (RetainClient) FindOldestFile

func (c RetainClient) FindOldestFile(pattern string) (fs.FileInfo, error)

Jump to

Keyboard shortcuts

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