hook

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Type of resources created by nfs-provisioner
	ResourceBackendPVC int = iota
	ResourceBackendPV
	ResourceNFSService
	ResourceNFSPV
	ResourceNFSServerDeployment
)
View Source
const HookVersion = "1.0.0"

HookVersion represent the hook config version

Variables

View Source
var (
	// ActionForEventMap stores the supported EventType for all ActionType
	ActionForEventMap = map[ActionType]struct {
		evType EventType
		actOp  ActionOp
	}{
		ActionAddOnCreateVolumeEvent:    {/* contains filtered or unexported fields */},
		ActionRemoveOnCreateVolumeEvent: {/* contains filtered or unexported fields */},
		ActionAddOnDeleteVolumeEvent:    {/* contains filtered or unexported fields */},
		ActionRemoveOnDeleteVolumeEvent: {/* contains filtered or unexported fields */},
	}
)

Functions

func AddAnnotations

func AddAnnotations(objMeta *metav1.ObjectMeta, annotations map[string]string)

AddAnnotations add given annotations to given meta object Object annotations will be overridden if any of the given annotations exists with the same key

Types

type ActionOp

type ActionOp string

ActionOp represent the operation performed for ActionType

const (
	// ActionOpAddOrUpdate define Action addOrUpdateEntries
	ActionOpAddOrUpdate ActionOp = "addOrUpdateEntries"

	// ActionOpRemove define Action removeEntries
	ActionOpRemove ActionOp = "removeEntries"
)

type ActionType

type ActionType string

ActionType defines type of action for the hook entry

const (

	// ActionAddOnCreateVolumeEvent represent add action on volume create Event
	ActionAddOnCreateVolumeEvent ActionType = "addOrUpdateEntriesOnCreateVolumeEvent"

	// ActionRemoveOnCreateVolumeEvent represent remove action on volume create Event
	ActionRemoveOnCreateVolumeEvent ActionType = "removeEntriesOnCreateVolumeEvent"

	// ActionAddOnDeleteVolumeEvent represent add action on volume delete Event
	ActionAddOnDeleteVolumeEvent ActionType = "addOrUpdateEntriesOnDeleteVolumeEvent"

	// ActionRemoveOnDeleteVolumeEvent represent remove action on volume delete Event
	ActionRemoveOnDeleteVolumeEvent ActionType = "removeEntriesOnDeleteVolumeEvent"
)

type DeploymentHook

type DeploymentHook struct {
	// Annotations needs to be added/removed on/from the Deployment
	Annotations map[string]string `json:"annotations,omitempty"`

	// Finalizers needs to be added/removed on/from the Deployment
	Finalizers []string `json:"finalizers,omitempty"`
}

DeploymentHook defines the field which will be updated for Deployment Hook Action

type EventType

type EventType string

EventType defines the type of events on which hook needs to be executed

const (
	// EventTypeCreateVolume represent volume create event
	EventTypeCreateVolume EventType = "CreateVolume"

	// EventTypeDeleteVolume represent volume delete event
	EventTypeDeleteVolume EventType = "DeleteVolume"
)

type Hook

type Hook struct {
	//Config represent the list of HookConfig
	Config map[ActionType]HookConfig `json:"hooks"`

	// Version represent HookConfig format version; includes major, minor and patch version
	Version string `json:"version"`
	// contains filtered or unexported fields
}

Hook stores HookConfig and its version

func ParseHooks

func ParseHooks(hookData []byte) (*Hook, error)

ParseHooks will parse the given data and return generated Hook object

func (*Hook) Action

func (h *Hook) Action(obj interface{}, resourceType int, eventType EventType) error

Action run hooks for the given object type as per the event Action will skip further hook execution if any error occurred

func (*Hook) ActionExists

func (h *Hook) ActionExists(resourceType int, eventType EventType) bool

ActionExists will check if action exists for the give resource type and event type

func (*Hook) ExecuteHookOnBackendPV

func (h *Hook) ExecuteHookOnBackendPV(client kubernetes.Interface, ctx context.Context, ns, backendPvcName string, eventType EventType) error

ExecuteHookOnBackendPV will execute the hook on the PV for given PVC and patch it

func (*Hook) ExecuteHookOnBackendPVC

func (h *Hook) ExecuteHookOnBackendPVC(client kubernetes.Interface, ctx context.Context, ns, backendPvcName string, eventType EventType) error

ExecuteHookOnBackendPV will execute the hook on the PV for given PVC and patch it

func (*Hook) ExecuteHookOnNFSDeployment

func (h *Hook) ExecuteHookOnNFSDeployment(client kubernetes.Interface, ctx context.Context, ns, deployName string, eventType EventType) error

ExecuteHookOnNFSDeployment will execute the hook on the given deployment and patch it

func (*Hook) ExecuteHookOnNFSPV

func (h *Hook) ExecuteHookOnNFSPV(client kubernetes.Interface, ctx context.Context, pvName string, eventType EventType) error

ExecuteHookOnNFSPV will execute the hook on the given PV and patch it

func (*Hook) ExecuteHookOnNFSService

func (h *Hook) ExecuteHookOnNFSService(client kubernetes.Interface, ctx context.Context, ns, serviceName string, eventType EventType) error

ExecuteHookOnNFSService will execute the hook on the given service and patch it

type HookConfig

type HookConfig struct {
	// Name represent hook name
	Name string `json:"name"`

	// NFSPVConfig represent config for NFSPV resource
	NFSPVConfig *PVHook `json:"nfsPV,omitempty"`

	// BackendPVConfig represent config for BackendPV resource
	BackendPVConfig *PVHook `json:"backendPV,omitempty"`

	// BackendPVCConfig represent config for BackendPVC resource
	BackendPVCConfig *PVCHook `json:"backendPVC,omitempty"`

	// NFSServiceConfig represent config for NFS Service resource
	NFSServiceConfig *ServiceHook `json:"nfsService,omitempty"`

	// NFSDeploymentConfig represent config for NFS Deployment resource
	NFSDeploymentConfig *DeploymentHook `json:"nfsDeployment,omitempty"`
}

HookConfig represent the to be executed by nfs-provisioner

type PVCHook

type PVCHook struct {
	// Annotations needs to be added/removed on/from the PVC
	Annotations map[string]string `json:"annotations,omitempty"`

	// Finalizers needs to be added/removed on/from the PVC
	Finalizers []string `json:"finalizers,omitempty"`
}

PVCHook defines the field which will be updated for PVC Hook Action

type PVHook

type PVHook struct {
	// Annotations needs to be added/removed on/from the PV
	Annotations map[string]string `json:"annotations,omitempty"`

	// Finalizers needs to be added/removed on/from the PV
	Finalizers []string `json:"finalizers,omitempty"`
}

PVHook defines the field which will be updated for PV Hook Action

type ServiceHook

type ServiceHook struct {
	// Annotations needs to be added/removed on/from the Service
	Annotations map[string]string `json:"annotations,omitempty"`

	// Finalizers needs to be added/removed on/from the Service
	Finalizers []string `json:"finalizers,omitempty"`
}

ServiceHook defines the field which will be updated for Service Hook Action

type TemplateVarName

type TemplateVarName string

TemplateVarName represent template variable

const (
	// TemplateVarCurrentTime defines variable name for Current Time
	TemplateVarCurrentTime TemplateVarName = "$current-time"
)

Jump to

Keyboard shortcuts

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