Documentation
¶
Overview ¶
Package apps provides the Application type representing a running package instance. It manages hooks, values, and execution lifecycle for a single application.
Index ¶
- func BuildName(namespace, name string) string
- type Application
- func (a *Application) ApplySettings(settings addonutils.Values) error
- func (a *Application) DisableHooks()
- func (a *Application) GetConstraints() schedule.Constraints
- func (a *Application) GetHookSnapshotsDump() []byte
- func (a *Application) GetHooksByBinding(binding shtypes.BindingType) []hooks.Hook
- func (a *Application) GetHooksQueues() []string
- func (a *Application) GetInfo() Info
- func (a *Application) GetName() string
- func (a *Application) GetNamespace() string
- func (a *Application) GetPath() string
- func (a *Application) GetRuntimeValues() string
- func (a *Application) GetSettings() addonutils.Values
- func (a *Application) GetSettingsChecksum() string
- func (a *Application) GetValues() addonutils.Values
- func (a *Application) GetValuesChecksum() string
- func (a *Application) GetVersion() *semver.Version
- func (a *Application) HooksInitialized() bool
- func (a *Application) InitializeHooks()
- func (a *Application) RunHookByName(ctx context.Context, name string, bctx []bctx.BindingContext) error
- func (a *Application) RunHooksByBinding(ctx context.Context, binding shtypes.BindingType) error
- func (a *Application) UnlockKubernetesMonitors(hook string, monitors ...string)
- func (a *Application) ValidateSettings(ctx context.Context, settings addonutils.Values) (settingscheck.Result, error)
- type Config
- type Definition
- type Dependency
- type DisableOptions
- type Info
- type Requirements
- type RuntimeValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application represents a running instance of a package. It contains hooks, values storage, and configuration for execution.
Thread Safety: The Application itself is not thread-safe, but its hooks and values storage components use internal synchronization.
func NewAppByConfig ¶
NewAppByConfig creates a new Application 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 (*Application) ApplySettings ¶
func (a *Application) ApplySettings(settings addonutils.Values) error
ApplySettings applies settings values to application
func (*Application) DisableHooks ¶ added in v1.76.0
func (a *Application) DisableHooks()
DisableHooks tears down all active hook bindings and clears the hook registry. Called by the Disable task when a package is being stopped or upgraded.
Cleanup order: schedule bindings are disabled first (stops cron triggers), then Kubernetes monitors are stopped (stops informer watches), and finally the hook registry is cleared so a subsequent InitializeHooks starts fresh.
func (*Application) GetConstraints ¶ added in v1.76.0
func (a *Application) GetConstraints() schedule.Constraints
GetConstraints returns scheduler checks, their determine if an app should be enabled/disabled
func (*Application) GetHookSnapshotsDump ¶ added in v1.76.0
func (a *Application) GetHookSnapshotsDump() []byte
GetHookSnapshotsDump returns a YAML snapshot of hook controller snapshots.
func (*Application) GetHooksByBinding ¶
func (a *Application) GetHooksByBinding(binding shtypes.BindingType) []hooks.Hook
GetHooksByBinding returns all hooks for the specified binding type, sorted by order.
func (*Application) GetHooksQueues ¶ added in v1.76.0
func (a *Application) GetHooksQueues() []string
GetHooksQueues returns package queues from all hooks
func (*Application) GetInfo ¶
func (a *Application) GetInfo() Info
func (*Application) GetName ¶
func (a *Application) GetName() string
GetName returns the full application identifier in format "namespace.name".
func (*Application) GetNamespace ¶
func (a *Application) GetNamespace() string
GetNamespace returns the application namespace.
func (*Application) GetPath ¶
func (a *Application) GetPath() string
GetPath returns path to the package dir
func (*Application) GetRuntimeValues ¶
func (a *Application) GetRuntimeValues() string
GetRuntimeValues returns runtime values in string format
func (*Application) GetSettings ¶ added in v1.76.0
func (a *Application) GetSettings() addonutils.Values
GetSettings returns the effective settings: user config merged with config-schema defaults. Same payload exposed to templates as .Application.Settings.
func (*Application) GetSettingsChecksum ¶
func (a *Application) GetSettingsChecksum() string
GetSettingsChecksum returns a checksum of the current config values. Used to detect if settings changed.
func (*Application) GetValues ¶
func (a *Application) GetValues() addonutils.Values
GetValues returns values for hook rendering
func (*Application) GetValuesChecksum ¶
func (a *Application) GetValuesChecksum() string
GetValuesChecksum returns a checksum of the current values. Used to detect if values changed after hook execution.
func (*Application) GetVersion ¶
func (a *Application) GetVersion() *semver.Version
GetVersion return the package version
func (*Application) HooksInitialized ¶ added in v1.76.0
func (a *Application) HooksInitialized() bool
HooksInitialized reports whether the package requires a hook initialize phase. This is true when hooks have not yet been initialized (no controllers attached), meaning the pkg needs to go through the full startup sequence before it can run.
func (*Application) InitializeHooks ¶
func (a *Application) InitializeHooks()
InitializeHooks initializes hook controllers and bind them to Kubernetes events and schedules
func (*Application) RunHookByName ¶
func (a *Application) RunHookByName(ctx context.Context, name string, bctx []bctx.BindingContext) error
RunHookByName executes a specific hook by name with the provided binding context. Returns nil if hook is not found (silent no-op).
func (*Application) RunHooksByBinding ¶
func (a *Application) RunHooksByBinding(ctx context.Context, binding shtypes.BindingType) error
RunHooksByBinding executes all hooks for a specific binding type in order. It creates a binding context with snapshots for BeforeHelm/AfterHelm/AfterDeleteHelm hooks.
func (*Application) UnlockKubernetesMonitors ¶
func (a *Application) UnlockKubernetesMonitors(hook string, monitors ...string)
UnlockKubernetesMonitors called after sync task is completed to unlock getting events
func (*Application) ValidateSettings ¶
func (a *Application) ValidateSettings(ctx context.Context, settings addonutils.Values) (settingscheck.Result, error)
ValidateSettings validates settings against openAPI and call setting check if exists
type Config ¶
type Config struct {
Path string // Path to package dir
StaticValues addonutils.Values // Static values from values.yaml files
Definition Definition // Application definition
Digests map[string]string // Package images digests(images_digests.json)
Repository registry.Remote // Package repository options
ConfigSchema []byte // OpenAPI config schema (YAML)
ValuesSchema []byte // OpenAPI values schema (YAML)
Hooks []hooks.Hook // Discovered hooks
SettingsCheck *kind.SettingsCheck
Patcher *objectpatch.ObjectPatcher
ScheduleManager schedulemanager.ScheduleManager
KubeEventsManager kubeeventsmanager.KubeEventsManager
}
Config holds configuration for creating a new Application instance.
type Definition ¶
type Definition struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Stage string `json:"stage" yaml:"stage"`
Requirements Requirements `json:"requirements" yaml:"requirements"`
DisableOptions DisableOptions `json:"disableOptions" yaml:"disableOptions"`
}
Definition represents application metadata.
func (Definition) Constraints ¶ added in v1.76.0
func (d Definition) Constraints() schedule.Constraints
type Dependency ¶
type Dependency struct {
Constraints *semver.Constraints `json:"constraints" yaml:"constraints"`
Optional bool `json:"optional" yaml:"optional"`
}
type DisableOptions ¶
type DisableOptions struct {
Confirmation bool `json:"confirmation" yaml:"confirmation"` // Whether confirmation is required to disable
Message string `json:"message" yaml:"message"` // Message to display when disabling
}
DisableOptions configures application disablement behavior.
type Info ¶
type Info struct {
Instance string `json:"name" yaml:"name"`
Namespace string `json:"namespace" yaml:"namespace"`
Path string `json:"path" yaml:"path"`
Running bool `json:"running" yaml:"running"`
Definition Definition `json:"definition" yaml:"definition"`
Repository registry.Remote `json:"repository" yaml:"repository"`
Digests map[string]string `json:"digests" yaml:"digests"`
Values addonutils.Values `json:"values,omitempty" yaml:"values,omitempty"`
Hooks []string `json:"hooks,omitempty" yaml:"hooks,omitempty"`
}
type Requirements ¶
type Requirements struct {
Kubernetes *semver.Constraints `json:"kubernetes" yaml:"kubernetes"`
Deckhouse *semver.Constraints `json:"deckhouse" yaml:"deckhouse"`
Modules map[string]Dependency `json:"modules" yaml:"modules"`
}
Requirements specifies dependencies required by the application.
type RuntimeValues ¶
type RuntimeValues struct {
Instance addonutils.Values `json:"Instance"`
Package addonutils.Values `json:"Package"`
Settings addonutils.Values `json:"Settings"`
}
RuntimeValues holds runtime values that are not part of schema. These values are passed to helm templates under .Application prefix.