hook

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRateLimiter

func CreateRateLimiter(cfg *config.HookConfig) *rate.Limiter

Types

type CommonHook

type CommonHook interface {
	Name() string
}

type Hook

type Hook struct {
	Name   string // The unique name like '002-prometheus-hooks/startup_hook'.
	Path   string // The absolute path to the executable file.
	Config *config.HookConfig

	HookController *controller.HookController
	RateLimiter    *rate.Limiter

	TmpDir string
}

func NewHook

func NewHook(name, path string) *Hook

func (*Hook) GetConfig

func (h *Hook) GetConfig() *config.HookConfig

func (*Hook) GetConfigDescription

func (h *Hook) GetConfigDescription() string

func (*Hook) LoadConfig

func (h *Hook) LoadConfig(configOutput []byte) (hook *Hook, err error)

func (*Hook) RateLimitWait

func (h *Hook) RateLimitWait(ctx context.Context) error

func (*Hook) Run

func (h *Hook) Run(_ BindingType, context []BindingContext, logLabels map[string]string) (*Result, error)

func (*Hook) SafeName

func (h *Hook) SafeName() string

func (*Hook) WithHookController

func (h *Hook) WithHookController(hookController *controller.HookController)

func (*Hook) WithTmpDir

func (h *Hook) WithTmpDir(dir string)

type Manager added in v1.4.12

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

func NewHookManager

func NewHookManager(config *ManagerConfig) *Manager

func (*Manager) DetectAdmissionEventType added in v1.4.12

func (hm *Manager) DetectAdmissionEventType(event admission.Event) BindingType

func (*Manager) FindConversionChain added in v1.4.12

func (hm *Manager) FindConversionChain(crdName string, rule conversion.Rule) []conversion.Rule

func (*Manager) GetHook added in v1.4.12

func (hm *Manager) GetHook(name string) *Hook

func (*Manager) GetHookNames added in v1.4.12

func (hm *Manager) GetHookNames() []string

func (*Manager) GetHooksInOrder added in v1.4.12

func (hm *Manager) GetHooksInOrder(bindingType BindingType) ([]string, error)

func (*Manager) HandleAdmissionEvent added in v1.4.12

func (hm *Manager) HandleAdmissionEvent(event admission.Event, createTaskFn func(*Hook, controller.BindingExecutionInfo))

func (*Manager) HandleConversionEvent added in v1.4.12

func (hm *Manager) HandleConversionEvent(crdName string, request *v1.ConversionRequest, rule conversion.Rule, createTaskFn func(*Hook, controller.BindingExecutionInfo))

HandleConversionEvent receives a crdName and calculates a sequence of hooks to run.

func (*Manager) HandleKubeEvent added in v1.4.12

func (hm *Manager) HandleKubeEvent(kubeEvent KubeEvent, createTaskFn func(*Hook, controller.BindingExecutionInfo))

func (*Manager) HandleScheduleEvent added in v1.4.12

func (hm *Manager) HandleScheduleEvent(crontab string, createTaskFn func(*Hook, controller.BindingExecutionInfo))

func (*Manager) Init added in v1.4.12

func (hm *Manager) Init() error

Init finds executables in WorkingDir, execute them with --config argument and add them into indices.

func (*Manager) TempDir added in v1.4.12

func (hm *Manager) TempDir() string

func (*Manager) UpdateConversionChains added in v1.4.12

func (hm *Manager) UpdateConversionChains() error

func (*Manager) WorkingDir added in v1.4.12

func (hm *Manager) WorkingDir() string

type ManagerConfig added in v1.4.12

ManagerConfig sets configuration for Manager

type Result added in v1.4.12

type Result struct {
	Usage                *executor.CmdUsage
	Metrics              []operation.MetricOperation
	ConversionResponse   *conversion.Response
	AdmissionResponse    *admission.Response
	KubernetesPatchBytes []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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