hook

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook v1.Hook

func (*Hook) Do

func (h *Hook) Do(event v1.Hook_Condition, vars HookVars, output io.Writer) error

type HookErrorFatal added in v0.17.0

type HookErrorFatal struct {
	Err error
}

HookErrorFatal stops evaluation of subsequent hooks and will propagate to the hook flow's caller

func (HookErrorFatal) Error added in v0.17.0

func (e HookErrorFatal) Error() string

func (HookErrorFatal) Unwrap added in v0.17.0

func (e HookErrorFatal) Unwrap() error

type HookErrorRequestCancel added in v0.17.0

type HookErrorRequestCancel struct {
	Err error
}

HookErrorCancel requests that the calling operation cancel itself. It must be handled explicitly caller. Subsequent hooks will be skipped.

func (HookErrorRequestCancel) Error added in v0.17.0

func (e HookErrorRequestCancel) Error() string

func (HookErrorRequestCancel) Unwrap added in v0.17.0

func (e HookErrorRequestCancel) Unwrap() error

type HookExecutor

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

func NewHookExecutor

func NewHookExecutor(config *v1.Config, oplog *oplog.OpLog, bigOutputStore *rotatinglog.RotatingLog) *HookExecutor

func (*HookExecutor) ExecuteHooks

func (e *HookExecutor) ExecuteHooks(flowID int64, repo *v1.Repo, plan *v1.Plan, events []v1.Hook_Condition, vars HookVars) error

ExecuteHooks schedules tasks for the hooks subscribed to the given event. The vars map is used to substitute variables Hooks are pulled both from the provided plan and from the repo config.

type HookVars

type HookVars struct {
	Task          string                      // the name of the task that triggered the hook.
	Event         v1.Hook_Condition           // the event that triggered the hook.
	Repo          *v1.Repo                    // the v1.Repo that triggered the hook.
	Plan          *v1.Plan                    // the v1.Plan that triggered the hook.
	SnapshotId    string                      // the snapshot ID that triggered the hook.
	SnapshotStats *restic.BackupProgressEntry // the summary of the backup operation.
	CurTime       time.Time                   // the current time as time.Time
	Duration      time.Duration               // the duration of the operation that triggered the hook.
	Error         string                      // the error that caused the hook to run as a string.
}

HookVars is the set of variables that are available to a hook. Some of these are optional. NOTE: names of HookVars may change between versions of backrest. This is not a guaranteed stable API. when names change hooks will require updating.

func (HookVars) EventName

func (v HookVars) EventName(cond v1.Hook_Condition) string

func (HookVars) FormatDuration added in v1.0.0

func (v HookVars) FormatDuration(d time.Duration) string

func (HookVars) FormatSizeBytes

func (v HookVars) FormatSizeBytes(val any) string

func (HookVars) FormatTime

func (v HookVars) FormatTime(t time.Time) string

func (HookVars) IsError

func (v HookVars) IsError(cond v1.Hook_Condition) bool

func (HookVars) JsonMarshal

func (v HookVars) JsonMarshal(s any) string

func (HookVars) ShellEscape

func (v HookVars) ShellEscape(s string) string

func (HookVars) Summary

func (v HookVars) Summary() (string, error)

Jump to

Keyboard shortcuts

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