Documentation
¶
Index ¶
- type Config
- type Info
- type Module
- func (m *Module) ApplySettings(settingsVersion int, settings addonutils.Values) error
- func (m *Module) DisableHooks()
- func (m *Module) GetConstraints() schedule.Constraints
- func (m *Module) GetHookSnapshotsDump() map[string]any
- func (m *Module) GetHooksByBinding(binding shtypes.BindingType) []hooks.ControllableHook
- func (m *Module) GetHooksQueues() []string
- func (m *Module) GetInfo() Info
- func (m *Module) GetName() string
- func (m *Module) GetPath() string
- func (m *Module) GetSettings() addonutils.Values
- func (m *Module) GetValue(key string) (any, bool)
- func (m *Module) GetValues() addonutils.Values
- func (m *Module) GetValuesChecksum() string
- func (m *Module) GetVersion() *semver.Version
- func (m *Module) InitializeHooks()
- func (m *Module) IsEnabled(moduleName string) *bool
- func (m *Module) LatestSettingsVersion() int
- func (m *Module) RunHookByName(ctx context.Context, name string, bctx []bctx.BindingContext) error
- func (m *Module) RunHooksByBinding(ctx context.Context, binding shtypes.BindingType) error
- func (m *Module) SetCapabilities(apiVersions []string)
- func (m *Module) SetEnabledModules(enabledModules []string)
- func (m *Module) SetModulesImagesDigests(digests map[string]map[string]string)
- func (m *Module) UnlockKubernetesMonitors(hook string, monitors ...string)
- func (m *Module) ValidateSettings(_ context.Context, settingsVersion int, settings addonutils.Values) (settingscheck.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Path string // Path to package dir
StaticValues addonutils.Values // Static values from values.yaml files
// Version is the deckhouse image's version, the one the global Module's spec names; "v0.0.0" when
// it does not parse.
Version string
ConfigSchema []byte // OpenAPI config schema (YAML)
ValuesSchema []byte // OpenAPI values schema (YAML)
Hooks []hooks.GlobalHook // Discovered hooks
Conversions *conversion.Converter // Schema version converter
MetricStorage metricsstorage.Storage
Patcher *objectpatch.ObjectPatcher
ScheduleManager schedulemanager.ScheduleManager
KubeEventsManager kubeeventsmanager.KubeEventsManager
// OnDynamicChange is called after a global hook changed a module's signal (set, flipped or
// removed; see filterEnabledFromValuesPatch), from the goroutine that ran the hook, with no lock
// of the module held. Why: the signal is stripped from the values patch, so the values checksum
// does not change and nothing else tells the scheduler to read IsEnabled again; the package
// engine wires it to its recompute. Must not block for long. Nil: nobody listens.
OnDynamicChange func()
}
Config holds configuration for creating a new Module instance.
type Info ¶ added in v1.77.0
type Info struct {
Name string `json:"name" yaml:"name"`
Path string `json:"path" yaml:"path"`
Values addonutils.Values `json:"values,omitempty" yaml:"values,omitempty"`
Hooks []string `json:"hooks,omitempty" yaml:"hooks,omitempty"`
Dynamic map[string]bool `json:"dynamic,omitempty" yaml:"dynamic,omitempty"`
}
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func NewModuleByConfig ¶
NewModuleByConfig creates a new Module instance with the specified configuration. It initializes hook storage, adds all discovered hooks, and creates values storage.
Returns error if hook initialization or values storage creation fails.
func (*Module) ApplySettings ¶
func (m *Module) ApplySettings(settingsVersion int, settings addonutils.Values) error
ApplySettings converts settings to the latest schema version (if a converter is available), then applies them to the values storage.
func (*Module) DisableHooks ¶ added in v1.78.0
func (m *Module) DisableHooks()
DisableHooks stops the hook bindings and drops the controllers, so the next InitializeHooks starts fresh. Called by the lanes' stop (hooklane): after a synchronization that failed midway and when Global exits.
func (*Module) GetConstraints ¶ added in v1.77.0
func (m *Module) GetConstraints() schedule.Constraints
GetConstraints returns the scheduler constraints for the global module: it sits at order 0 (the barrier ahead of every other package) and is always enabled. Not registered with the scheduler yet — see the global-node wiring in runtime.
func (*Module) GetHookSnapshotsDump ¶ added in v1.77.0
GetHookSnapshotsDump returns the snapshots of the hooks' unlocked monitors (hooks.SnapshotsDump).
func (*Module) GetHooksByBinding ¶ added in v1.77.0
func (m *Module) GetHooksByBinding(binding shtypes.BindingType) []hooks.ControllableHook
GetHooksByBinding returns the global hooks for the binding as the ControllableHook view, so the hook lanes drive global like any package.
func (*Module) GetHooksQueues ¶ added in v1.78.0
GetHooksQueues returns the queues of the global hooks' schedule and Kubernetes bindings, sorted and without duplicates.
func (*Module) GetSettings ¶ added in v1.77.0
func (m *Module) GetSettings() addonutils.Values
GetSettings returns the effective settings: user config merged with config-schema defaults. Same payload exposed to templates as .Module.Settings.
func (*Module) GetValue ¶ added in v1.78.0
GetValue is the global value at key, without the copies GetValues makes for rendering: the scheduler's getters read one key on every computation. The value is shared and must not be changed; the digests GetValues merges in are not part of it.
func (*Module) GetValues ¶
func (m *Module) GetValues() addonutils.Values
GetValues returns values for rendering.
Global values are exposed both flat (.Values.replicas) and under the "global" key (.Values.global.replicas) so templates written for the old addon-operator layout keep working.
The enabled modules' image digests are merged into modulesImages.digests here, over the ones the global hook read from the image, and not kept in the values: GetValuesChecksum, Global's Output, does not hash them, so a module update reruns only that module's subscribers.
func (*Module) GetValuesChecksum ¶
GetValuesChecksum returns a checksum of the current values. Used to detect if values changed after hook execution.
func (*Module) GetVersion ¶
GetVersion returns the deckhouse image's version (Config.Version).
func (*Module) InitializeHooks ¶
func (m *Module) InitializeHooks()
InitializeHooks initializes hook controllers and bind them to Kubernetes events and schedules
func (*Module) IsEnabled ¶ added in v1.77.0
IsEnabled is the global hooks' signal of a module (kebab-case name) for the scheduler: the value a hook set last, or nil when none is set. Safe for concurrent use.
func (*Module) LatestSettingsVersion ¶ added in v1.78.0
LatestSettingsVersion returns the latest settings-schema version, the one effective settings are in; 0 without a converter.
func (*Module) RunHookByName ¶
RunHookByName runs some specified hook by its name
func (*Module) RunHooksByBinding ¶
RunHooksByBinding executes all hooks for a specific binding type in order. It creates a binding context with snapshots for BeforeAll hooks.
func (*Module) SetCapabilities ¶ added in v1.77.0
SetCapabilities injects the GVKs Global's ensureCRDs step installed into the .capabilities global value, exposed to charts as .Platform.capabilities
func (*Module) SetEnabledModules ¶ added in v1.77.0
SetEnabledModules inject enabledModules to the global values enabledModules are injected as a patch, to recalculate on every global values change
func (*Module) SetModulesImagesDigests ¶ added in v1.78.0
SetModulesImagesDigests replaces the image digests of the enabled modules, by module name (kebab-case): charts on the legacy helm_lib read another module's images from modulesImages.digests by its camelCase name.
func (*Module) UnlockKubernetesMonitors ¶
UnlockKubernetesMonitors is called after a binding's synchronization ran, so its events flow.
func (*Module) ValidateSettings ¶
func (m *Module) ValidateSettings(_ context.Context, settingsVersion int, settings addonutils.Values) (settingscheck.Result, error)
ValidateSettings converts settings to the latest schema version (if a converter is available), then validates against OpenAPI schema.