Documentation
¶
Index ¶
- type Config
- type Manager
- func (m *Manager) ApplySettings(name string, settings addonutils.Values) error
- func (m *Manager) BuildKubeTasks(ctx context.Context, kubeEvent shkubetypes.KubeEvent, builder TaskBuilder) map[string][]queue.Task
- func (m *Manager) BuildScheduleTasks(ctx context.Context, crontab string, builder TaskBuilder) map[string][]queue.Task
- func (m *Manager) DisablePackage(ctx context.Context, name string, keep bool) error
- func (m *Manager) GetAppInfo(name string) apps.Info
- func (m *Manager) GetApplication(name string) *apps.Application
- func (m *Manager) GetPackageQueues(name string) []string
- func (m *Manager) InitializeHooks(ctx context.Context, name string) (map[string][]hookcontroller.BindingExecutionInfo, error)
- func (m *Manager) KubeObjectPatcher() *objectpatch.ObjectPatcher
- func (m *Manager) LoadPackage(ctx context.Context, registry registry.Registry, namespace, name string) error
- func (m *Manager) RunPackage(ctx context.Context, name string) error
- func (m *Manager) RunPackageHook(ctx context.Context, name, hook string, bctx []bindingcontext.BindingContext) error
- func (m *Manager) SettingsChanged(name string, settings addonutils.Values) bool
- func (m *Manager) StartupPackage(ctx context.Context, name string) error
- func (m *Manager) UnlockKubernetesMonitors(name, hook string, monitors ...string)
- func (m *Manager) VersionChanged(name, version string) bool
- type TaskBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
OnValuesChanged func(ctx context.Context, name string)
NelmService *nelm.Service
KubeObjectPatcher *objectpatch.ObjectPatcher
ScheduleManager schedulemanager.ScheduleManager
KubeEventsManager kubeeventsmanager.KubeEventsManager
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the lifecycle of application packages.
func (*Manager) ApplySettings ¶
func (m *Manager) ApplySettings(name string, settings addonutils.Values) error
ApplySettings validates and apply setting to application
func (*Manager) BuildKubeTasks ¶
func (m *Manager) BuildKubeTasks(ctx context.Context, kubeEvent shkubetypes.KubeEvent, builder TaskBuilder) map[string][]queue.Task
BuildKubeTasks converts a Kubernetes event into executable tasks for all matching hooks.
For each application:
- Find hooks that are bound to Kubernetes events
- Check if the hook can handle this specific event (filtering)
- Generate tasks for matching hooks using the provided builder
Returns a map of queue names to tasks, allowing different hooks to be routed to different queues (e.g., priority queues, sequential queues).
func (*Manager) BuildScheduleTasks ¶
func (m *Manager) BuildScheduleTasks(ctx context.Context, crontab string, builder TaskBuilder) map[string][]queue.Task
BuildScheduleTasks converts a schedule (cron) event into executable tasks for all matching hooks.
For each application:
- Find hooks that are bound to schedule events
- Check if the hook's schedule matches the triggered crontab
- Generate tasks for matching hooks using the provided builder
Returns a map of queue names to tasks, allowing hooks to specify their execution queue.
func (*Manager) DisablePackage ¶
DisablePackage stops monitoring, uninstalls helm release and disables all hooks for a package.
Process:
- Stop Helm resource monitoring
- Uninstall Helm release
- Run AfterDeleteHelm hooks
- Disable all schedule hooks
- Stop all Kubernetes event monitors
- Remove package from manager store
func (*Manager) GetApplication ¶
func (m *Manager) GetApplication(name string) *apps.Application
func (*Manager) GetPackageQueues ¶
GetPackageQueues collects all queues from package hooks
func (*Manager) InitializeHooks ¶
func (m *Manager) InitializeHooks(ctx context.Context, name string) (map[string][]hookcontroller.BindingExecutionInfo, error)
InitializeHooks initializes hook controllers and returns info for sync tasks.
This must be called after LoadApplication and before StartupPackage. It performs:
- Creates hook controllers for each hook
- Initializes Kubernetes event bindings
- Initializes schedule bindings
- Enables kube hooks(starting monitoring for the resources configured in each hook's bindings)
- Enable schedule hooks(activating the cron schedules configured in each hook's bindings)
func (*Manager) KubeObjectPatcher ¶
func (m *Manager) KubeObjectPatcher() *objectpatch.ObjectPatcher
KubeObjectPatcher returns the Kubernetes object patcher for applying patches from hooks.
This implements the DependencyContainer interface required by hook execution. Hooks can request object patching operations (create/update/delete K8s resources) during their execution, which are applied through this patcher.
func (*Manager) LoadPackage ¶
func (m *Manager) LoadPackage(ctx context.Context, registry registry.Registry, namespace, name string) error
LoadPackage loads a package from filesystem and stores it in the manager. It discovers hooks, parses OpenAPI schemas, and initializes values storage.
func (*Manager) RunPackage ¶
RunPackage executes the full package run cycle: BeforeHelm → Install/Upgrade → AfterHelm.
Process:
- Pause Helm resource monitoring
- Run BeforeHelm hooks (can modify values or prepare resources)
- Install or upgrade Helm release
- Run AfterHelm hooks
- If values changed during AfterHelm, trigger Helm upgrade
- Resume Helm resource monitoring
func (*Manager) RunPackageHook ¶
func (m *Manager) RunPackageHook(ctx context.Context, name, hook string, bctx []bindingcontext.BindingContext) error
RunPackageHook executes a specific hook by name with the provided binding context.
This is called when:
- Kubernetes events trigger a hook (resource created/updated/deleted)
- Schedule triggers fire (cron-like schedules)
Returns:
- bool: true if hook modified values (may require Helm upgrade)
- error: if hook execution fails
func (*Manager) SettingsChanged ¶
func (m *Manager) SettingsChanged(name string, settings addonutils.Values) bool
func (*Manager) StartupPackage ¶
StartupPackage runs OnStartup hooks for a package. This must be called after InitializeHooks and before RunPackage.
func (*Manager) UnlockKubernetesMonitors ¶
UnlockKubernetesMonitors called after sync task is completed to unlock getting events
func (*Manager) VersionChanged ¶
type TaskBuilder ¶
type TaskBuilder func(ctx context.Context, name, hook string, info hookcontroller.BindingExecutionInfo) (string, queue.Task)
TaskBuilder is a function that converts a hook binding execution into a queue task. It returns:
- string: the queue name to enqueue the task into (allows routing to different queues)
- queue.Task: the task to be executed
The builder is provided by the caller (typically the event handler) to customize task creation based on the specific execution context and requirements.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apps provides the Application type representing a running package instance.
|
Package apps provides the Application type representing a running package instance. |
|
monitor
Package monitor provides resource monitoring for Helm releases deployed via nelm.
|
Package monitor provides resource monitoring for Helm releases deployed via nelm. |