hook

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: Apache-2.0 Imports: 35 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRateLimiter

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

func ValidateMetricOperation added in v1.11.0

func ValidateMetricOperation(op MetricOperation) error

func ValidateOperations added in v1.11.0

func ValidateOperations(ops []MetricOperation) error

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
	KeepTemporaryHookFiles bool

	LogProxyHookJSON    bool
	LogProxyHookJSONKey string

	Logger *log.Logger
}

func NewHook

func NewHook(name, path string, keepTemporaryHookFiles bool, logProxyHookJSON bool, logProxyHookJSONKey string, logger *log.Logger) *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, error)

func (*Hook) RateLimitWait

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

func (*Hook) Run

func (h *Hook) Run(ctx context.Context, _ htypes.BindingType, context []bctx.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) CreateTasksFromKubeEvent added in v1.7.0

func (hm *Manager) CreateTasksFromKubeEvent(kubeEvent kemtypes.KubeEvent, createTaskFn func(*Hook, controller.BindingExecutionInfo) task.Task) []task.Task

func (*Manager) DetectAdmissionEventType added in v1.4.12

func (hm *Manager) DetectAdmissionEventType(event admission.Event) htypes.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 htypes.BindingType) ([]string, error)

func (*Manager) HandleAdmissionEvent added in v1.4.12

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

func (*Manager) HandleConversionEvent added in v1.4.12

func (hm *Manager) HandleConversionEvent(ctx context.Context, 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) HandleCreateTasksFromScheduleEvent added in v1.7.0

func (hm *Manager) HandleCreateTasksFromScheduleEvent(crontab string, createTaskFn func(*Hook, controller.BindingExecutionInfo) task.Task) []task.Task

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

type ManagerConfig struct {
	WorkingDir string
	TempDir    string
	Kmgr       kubeeventsmanager.KubeEventsManager
	Smgr       schedulemanager.ScheduleManager
	Wmgr       *admission.WebhookManager
	Cmgr       *conversion.WebhookManager

	Logger *log.Logger
}

ManagerConfig sets configuration for Manager

type MetricOperation added in v1.11.0

type MetricOperation struct {
	Name string `json:"name"`
	// Deprecated: use Value + Action="add" instead. Add only works for parsing from file
	Add *float64 `json:"add,omitempty"` // shortcut for action=add value=num
	// Deprecated: use Value + Action="set" instead. Set only works for parsing from file
	Set     *float64          `json:"set,omitempty"` // shortcut for action=set value=num
	Value   *float64          `json:"value,omitempty"`
	Buckets []float64         `json:"buckets,omitempty"`
	Labels  map[string]string `json:"labels"`
	Group   string            `json:"group,omitempty"`
	Action  string            `json:"action,omitempty"`
}

func MetricOperationsFromBytes added in v1.11.0

func MetricOperationsFromBytes(data []byte, defaultGroup string) ([]MetricOperation, error)

func MetricOperationsFromFile added in v1.11.0

func MetricOperationsFromFile(filePath, defaultGroup string) ([]MetricOperation, error)

func MetricOperationsFromReader added in v1.11.0

func MetricOperationsFromReader(r io.Reader, defaultGroup string) ([]MetricOperation, error)

func (MetricOperation) String added in v1.11.0

func (m MetricOperation) String() string

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