hook

package
v1.5.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PhasePre  hookPhase = "pre"
	PhasePost hookPhase = "post"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultItemHookHandler

type DefaultItemHookHandler struct {
	PodCommandExecutor podexec.PodCommandExecutor
}

DefaultItemHookHandler is the default itemHookHandler.

func (*DefaultItemHookHandler) HandleHooks

func (h *DefaultItemHookHandler) HandleHooks(
	log logrus.FieldLogger,
	groupResource schema.GroupResource,
	obj runtime.Unstructured,
	resourceHooks []ResourceHook,
	phase hookPhase,
) error

type InitContainerRestoreHookHandler

type InitContainerRestoreHookHandler struct{}

InitContainerRestoreHookHandler is the restore hook handler to add init containers to restored pods.

func (*InitContainerRestoreHookHandler) HandleRestoreHooks

func (i *InitContainerRestoreHookHandler) HandleRestoreHooks(
	log logrus.FieldLogger,
	groupResource schema.GroupResource,
	obj runtime.Unstructured,
	resourceRestoreHooks []ResourceRestoreHook,
) (runtime.Unstructured, error)

HandleRestoreHooks runs the restore hooks for an item. If the item is a pod, then hooks are chosen to be run as follows: If the pod has the appropriate annotations specifying the hook action, then hooks from the annotation are run Otherwise, the supplied ResourceRestoreHooks are applied.

type ItemHookHandler

type ItemHookHandler interface {
	// HandleHooks invokes hooks for an item. If the item is a pod and the appropriate annotations exist
	// to specify a hook, that is executed. Otherwise, this looks at the backup context's Backup to
	// determine if there are any hooks relevant to the item, taking into account the hook spec's
	// namespaces, resources, and label selector.
	HandleHooks(
		log logrus.FieldLogger,
		groupResource schema.GroupResource,
		obj runtime.Unstructured,
		resourceHooks []ResourceHook,
		phase hookPhase,
	) error
}

ItemHookHandler invokes hooks for an item.

type ItemRestoreHookHandler

type ItemRestoreHookHandler interface {
	HandleRestoreHooks(
		log logrus.FieldLogger,
		groupResource schema.GroupResource,
		obj runtime.Unstructured,
		rh []ResourceRestoreHook,
	) (runtime.Unstructured, error)
}

ItemRestoreHookHandler invokes restore hooks for an item

type ResourceHook

type ResourceHook struct {
	Name     string
	Selector ResourceHookSelector
	Pre      []velerov1api.BackupResourceHook
	Post     []velerov1api.BackupResourceHook
}

ResourceHook is a hook for a given resource.

type ResourceHookSelector

type ResourceHookSelector struct {
	Namespaces    *collections.IncludesExcludes
	Resources     *collections.IncludesExcludes
	LabelSelector labels.Selector
}

type ResourceRestoreHook

type ResourceRestoreHook struct {
	Name         string
	Selector     ResourceHookSelector
	RestoreHooks []velerov1api.RestoreResourceHook
}

ResourceRestoreHook is a restore hook for a given resource.

func GetRestoreHooksFromSpec

func GetRestoreHooksFromSpec(hooksSpec *velerov1api.RestoreHooks) ([]ResourceRestoreHook, error)

GetRestoreHooksFromSpec returns a list of ResourceRestoreHooks from the restore Spec.

Jump to

Keyboard shortcuts

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