go_hook

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 106

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyWrapped             = errors.New("empty filter result")
	ErrUnmarshalToTypesNotMatch = errors.New("input and output types not match")
)

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to a bool.

func BoolDeref

func BoolDeref(ptr *bool, def bool) bool

BoolDeref dereferences the bool ptr and returns it if not nil, or else returns def.

Types

type BindingAction

type BindingAction struct {
	Name       string // binding name
	Action     string // Disable / UpdateKind
	Kind       string
	ApiVersion string
}

type FilterFunc

type FilterFunc func(*unstructured.Unstructured) (FilterResult, error)

type FilterResult

type FilterResult any

type GoHook

type GoHook interface {
	Config() *HookConfig
	Run(input *sdkpkg.HookInput) error
}

type HookBindingContext

type HookBindingContext struct {
	// Type of binding context: [Event, Synchronization, Group, Schedule]
	Type string
	// Binding is a related binding name.
	Binding string
	// Snapshots contain all objects for all bindings.
	Snapshots map[string][]types.ObjectAndFilterResult
}

type HookConfig

type HookConfig struct {
	Schedule   []ScheduleConfig
	Kubernetes []KubernetesConfig
	// OnStartup runs hook on module/global startup
	// Attention! During the startup you don't have snapshots available
	// use native KubeClient to fetch resources
	OnStartup         *OrderedConfig
	OnBeforeHelm      *OrderedConfig
	OnAfterHelm       *OrderedConfig
	OnAfterDeleteHelm *OrderedConfig
	OnBeforeAll       *OrderedConfig
	OnAfterAll        *OrderedConfig
	AllowFailure      bool
	Queue             string
	Settings          *HookConfigSettings
	Logger            *log.Logger
}

type HookConfigLoader added in v1.6.0

type HookConfigLoader interface {
	GetConfigForModule(moduleKind string) (*config.HookConfig, error)
	GetOnStartup() *float64
	GetBeforeAll() *float64
	GetAfterAll() *float64
	GetAfterDeleteHelm() *float64
}

type HookConfigSettings

type HookConfigSettings struct {
	ExecutionMinInterval time.Duration
	ExecutionBurst       int

	// EnableSchedulesOnStartup
	// set to true, if you need to run 'Schedule' hooks without waiting addon-operator readiness
	EnableSchedulesOnStartup bool
}

type HookInput

type HookInput struct {
	Snapshots sdkpkg.Snapshots

	Values           sdkpkg.PatchableValuesCollector
	ConfigValues     sdkpkg.PatchableValuesCollector
	MetricsCollector sdkpkg.MetricsCollector
	PatchCollector   PatchCollector

	Logger Logger

	BindingActions *[]BindingAction
}

type HookMetadata

type HookMetadata struct {
	Name           string
	Path           string
	Global         bool
	EmbeddedModule bool
	ModuleName     string
}

type KubernetesConfig

type KubernetesConfig struct {
	// Name is a key in snapshots map.
	Name string
	// ApiVersion of objects. "v1" is used if not set.
	ApiVersion string
	// Kind of objects.
	Kind string
	// NameSelector used to subscribe on object by its name.
	NameSelector *types.NameSelector
	// NamespaceSelector used to subscribe on objects in namespaces.
	NamespaceSelector *types.NamespaceSelector
	// LabelSelector used to subscribe on objects by matching their labels.
	LabelSelector *v1.LabelSelector
	// FieldSelector used to subscribe on objects by matching specific fields (the list of fields is narrow, see shell-operator documentation).
	FieldSelector *types.FieldSelector
	// ExecuteHookOnEvents is true by default. Set to false if only snapshot update is needed.
	ExecuteHookOnEvents *bool
	// ExecuteHookOnSynchronization is true by default. Set to false if only snapshot update is needed.
	ExecuteHookOnSynchronization *bool
	// WaitForSynchronization is true by default. Set to false if beforeHelm is not required this snapshot on start.
	WaitForSynchronization *bool
	// FilterFunc used to filter object content for snapshot. Addon-operator use checksum of this filtered result to ignore irrelevant events.
	FilterFunc FilterFunc
}

type Logger added in v1.6.0

type Logger interface {
	sdkpkg.Logger

	// Deprecated: use Debug instead
	Debugf(format string, args ...any)
	// Deprecated: use Error instead
	Errorf(format string, args ...any)
	// Deprecated: use Fatal instead
	Fatalf(format string, args ...any)
	// Deprecated: use Info instead
	Infof(format string, args ...any)
	// Deprecated: use Log instead
	Logf(ctx context.Context, level log.Level, format string, args ...any)
	// Deprecated: use Warn instead
	Warnf(format string, args ...any)
}

type OrderedConfig

type OrderedConfig struct {
	Order float64
}

type PatchCollector added in v1.6.0

type PatchCollector interface {
	sdkpkg.PatchCollector

	PatchWithMutatingFunc(fn func(*unstructured.Unstructured) (*unstructured.Unstructured, error), apiVersion string, kind string, namespace string, name string, opts ...sdkpkg.PatchCollectorOption)
}

type ScheduleConfig

type ScheduleConfig struct {
	Name string
	// Crontab is a schedule config in crontab format. (5 or 6 fields)
	Crontab string
}

type Snapshots

type Snapshots map[string][]sdkpkg.Snapshot

type Snapshots map[string][]Wrapped

func (Snapshots) Get added in v1.12.1

func (s Snapshots) Get(name string) []sdkpkg.Snapshot

type Wrapped added in v1.7.7

type Wrapped struct {
	Wrapped any
}

func (*Wrapped) String added in v1.7.7

func (f *Wrapped) String() string

func (*Wrapped) UnmarshalTo added in v1.7.7

func (f *Wrapped) UnmarshalTo(v any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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