modules

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 33 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicModule

type BasicModule struct {
	// required
	Name string
	// required
	Order uint32
	// required
	Path string
	// contains filtered or unexported fields
}

BasicModule is a basic representation of the Module, which addon-operator works with any Module has the next parameters:

  • name of the module
  • order of the module execution
  • path of the module on a filesystem
  • values storage - config and calculated values for the module
  • hooks of the module
  • current module state

func NewBasicModule

func NewBasicModule(name, path string, order uint32, staticValues utils.Values, validator validator) *BasicModule

NewBasicModule creates new BasicModule staticValues - are values from modules/values.yaml and /modules/<module-name>/values.yaml, they could not be changed during the runtime

func (*BasicModule) ApplyNewStaticValues added in v1.3.12

func (bm *BasicModule) ApplyNewStaticValues(values utils.Values) error

ApplyNewStaticValues sets the module's static values and recalculate the resulting values

func (*BasicModule) DeregisterHooks

func (bm *BasicModule) DeregisterHooks()

DeregisterHooks clean up all module hooks

func (*BasicModule) GenerateNewConfigValues

func (bm *BasicModule) GenerateNewConfigValues(kubeConfigValues utils.Values, validate bool) (utils.Values, error)

func (*BasicModule) GetConfigValues

func (bm *BasicModule) GetConfigValues(withPrefix bool) utils.Values

func (*BasicModule) GetEnabledScriptResult added in v1.3.10

func (bm *BasicModule) GetEnabledScriptResult() *bool

GetEnabledScriptResult returns a bool pointer to the enabled script results

func (*BasicModule) GetHookByName

func (bm *BasicModule) GetHookByName(name string) *hooks.ModuleHook

GetHookByName returns hook by its name

func (*BasicModule) GetHookErrorsSummary added in v1.3.10

func (bm *BasicModule) GetHookErrorsSummary() string

GetHookErrorsSummary get hooks errors summary report

func (*BasicModule) GetHooks

func (bm *BasicModule) GetHooks(bt ...sh_op_types.BindingType) []*hooks.ModuleHook

GetHooks returns module hooks, they could be filtered by BindingType optionally

func (*BasicModule) GetLastHookError

func (bm *BasicModule) GetLastHookError() error

GetLastHookError get error of the last executed hook

func (*BasicModule) GetModuleError

func (bm *BasicModule) GetModuleError() error

func (*BasicModule) GetName

func (bm *BasicModule) GetName() string

GetName returns the module name

func (*BasicModule) GetOrder

func (bm *BasicModule) GetOrder() uint32

GetOrder returns the module order

func (*BasicModule) GetPath

func (bm *BasicModule) GetPath() string

GetPath returns the module path on a filesystem

func (*BasicModule) GetPhase

func (bm *BasicModule) GetPhase() ModuleRunPhase

GetPhase ...

func (*BasicModule) GetStaticValues added in v1.3.12

func (bm *BasicModule) GetStaticValues() utils.Values

GetStaticValues returns the module's static values

func (*BasicModule) GetValues

func (bm *BasicModule) GetValues(withPrefix bool) utils.Values

func (*BasicModule) GetValuesPatches

func (bm *BasicModule) GetValuesPatches() []utils.ValuesPatch

GetValuesPatches returns patches for debug output

func (*BasicModule) HasKubernetesHooks

func (bm *BasicModule) HasKubernetesHooks() bool

HasKubernetesHooks is true if module has at least one kubernetes hook.

func (*BasicModule) HooksControllersReady added in v1.3.9

func (bm *BasicModule) HooksControllersReady() bool

HooksControllersReady returns controllersReady status of the hook storage

func (*BasicModule) RegisterHooks

func (bm *BasicModule) RegisterHooks(logger *log.Entry) ([]*hooks.ModuleHook, error)

RegisterHooks find and registers all module hooks from a filesystem or GoHook Registry

func (*BasicModule) ResetState

func (bm *BasicModule) ResetState()

ResetState drops the module state

func (*BasicModule) RunEnabledScript

func (bm *BasicModule) RunEnabledScript(tmpDir string, precedingEnabledModules []string, logLabels map[string]string) (bool, error)

RunEnabledScript executate enabled script

func (*BasicModule) RunHookByName

func (bm *BasicModule) RunHookByName(hookName string, binding sh_op_types.BindingType, bindingContext []binding_context.BindingContext, logLabels map[string]string) (string, string, error)

RunHookByName runs some specified hook by its name

func (*BasicModule) RunHooksByBinding

func (bm *BasicModule) RunHooksByBinding(binding sh_op_types.BindingType, logLabels map[string]string) error

RunHooksByBinding gets all hooks for binding, for each hook it creates a BindingContext, sets KubernetesSnapshots and runs the hook.

func (*BasicModule) SaveConfigValues

func (bm *BasicModule) SaveConfigValues(configV utils.Values)

func (*BasicModule) SaveHookError

func (bm *BasicModule) SaveHookError(hookName string, err error)

SaveHookError ...

func (*BasicModule) SetError

func (bm *BasicModule) SetError(err error)

SetError ...

func (*BasicModule) SetHooksControllersReady added in v1.3.9

func (bm *BasicModule) SetHooksControllersReady()

SetHooksControllersReady sets controllersReady status of the hook storage to true

func (*BasicModule) SetPhase

func (bm *BasicModule) SetPhase(phase ModuleRunPhase)

SetPhase ...

func (*BasicModule) SetStateEnabled

func (bm *BasicModule) SetStateEnabled(e bool)

SetStateEnabled ...

func (*BasicModule) Synchronization

func (bm *BasicModule) Synchronization() *SynchronizationState

Synchronization xxx TODO: don't like this honestly, i think we can remake it

func (*BasicModule) SynchronizationNeeded

func (bm *BasicModule) SynchronizationNeeded() bool

SynchronizationNeeded is true if module has at least one kubernetes hook with executeHookOnSynchronization. TODO: dont skip

func (*BasicModule) WithDependencies

func (bm *BasicModule) WithDependencies(dep *hooks.HookExecutionDependencyContainer)

WithDependencies unject module dependencies

type EnabledPatchReport

type EnabledPatchReport struct {
	Patch utils.ValuesPatch
	Done  chan error
}

type GlobalModule

type GlobalModule struct {
	// contains filtered or unexported fields
}

GlobalModule is an ephemeral container for global hooks

func NewGlobalModule

func NewGlobalModule(hooksDir string, staticValues utils.Values, validator validator, dc *hooks.HookExecutionDependencyContainer) *GlobalModule

NewGlobalModule build ephemeral global container for global hooks and values

func (*GlobalModule) EnabledReportChannel

func (gm *GlobalModule) EnabledReportChannel() chan *EnabledPatchReport

EnabledReportChannel returns channel with dynamic modules enabling by global hooks

func (*GlobalModule) GenerateNewConfigValues

func (gm *GlobalModule) GenerateNewConfigValues(kubeConfigValues utils.Values, validate bool) (utils.Values, error)

func (*GlobalModule) GetConfigValues

func (gm *GlobalModule) GetConfigValues(withPrefix bool) utils.Values

func (*GlobalModule) GetHookByName

func (gm *GlobalModule) GetHookByName(name string) *hooks.GlobalHook

GetHookByName ...

func (*GlobalModule) GetHooks

func (gm *GlobalModule) GetHooks(bt ...sh_op_types.BindingType) []*hooks.GlobalHook

GetHooks returns module hooks, they could be filtered by BindingType optionally

func (*GlobalModule) GetName

func (gm *GlobalModule) GetName() string

GetName ...

func (*GlobalModule) GetValues

func (gm *GlobalModule) GetValues(withPrefix bool) utils.Values

func (*GlobalModule) GetValuesPatches

func (gm *GlobalModule) GetValuesPatches() []utils.ValuesPatch

func (*GlobalModule) RegisterHooks

func (gm *GlobalModule) RegisterHooks() ([]*hooks.GlobalHook, error)

RegisterHooks finds and registers global hooks

func (*GlobalModule) RunHookByName

func (gm *GlobalModule) RunHookByName(hookName string, binding sh_op_types.BindingType, bindingContext []binding_context.BindingContext, logLabels map[string]string) (string, string, error)

RunHookByName runs some specified hook by its name

func (*GlobalModule) SaveConfigValues

func (gm *GlobalModule) SaveConfigValues(configV utils.Values)

func (*GlobalModule) SetEnabledModules added in v1.3.5

func (gm *GlobalModule) SetEnabledModules(enabledModules []string)

SetEnabledModules inject enabledModules to the global values enabledModules are injected as a patch, to recalculate on every global values change

type HelmModule

type HelmModule struct {
	// contains filtered or unexported fields
}

HelmModule representation of the module, which has Helm Chart and could be installed with the helm lib

func NewHelmModule

func NewHelmModule(bm *BasicModule, tmpDir string, deps *HelmModuleDependencies, validator HelmValuesValidator) (*HelmModule, error)

NewHelmModule build HelmModule from the Module templates and values + global values

func (*HelmModule) PrepareValuesYamlFile

func (hm *HelmModule) PrepareValuesYamlFile() (string, error)

func (*HelmModule) Render

func (hm *HelmModule) Render(namespace string, debug bool) (string, error)

func (*HelmModule) RunHelmInstall

func (hm *HelmModule) RunHelmInstall(logLabels map[string]string) error

type HelmModuleDependencies

type HelmModuleDependencies struct {
	HelmClientFactory   *helm.ClientFactory
	HelmResourceManager HelmResourceManager
	MetricsStorage      MetricsStorage
	HelmValuesValidator HelmValuesValidator
}

type HelmResourceManager

type HelmResourceManager interface {
	GetAbsentResources(manifests []manifest.Manifest, defaultNamespace string) ([]manifest.Manifest, error)
	StartMonitor(moduleName string, manifests []manifest.Manifest, defaultNamespace string)
	HasMonitor(moduleName string) bool
}

type HelmValuesValidator

type HelmValuesValidator interface {
	ValidateModuleHelmValues(string, utils.Values) error
}

type HooksStorage

type HooksStorage struct {
	// contains filtered or unexported fields
}

HooksStorage keep module hooks in order

func (*HooksStorage) AddHook

func (hs *HooksStorage) AddHook(hk *hooks.ModuleHook)

type MetricsStorage

type MetricsStorage interface {
	HistogramObserve(metric string, value float64, labels map[string]string, buckets []float64)
}

type ModuleRunPhase

type ModuleRunPhase string
const (
	// Startup - module is just enabled.
	Startup ModuleRunPhase = "Startup"
	// OnStartupDone - onStartup hooks are done.
	OnStartupDone ModuleRunPhase = "OnStartupDone"
	// QueueSynchronizationTasks - should queue Synchronization tasks.
	QueueSynchronizationTasks ModuleRunPhase = "QueueSynchronizationTasks"
	// WaitForSynchronization - some Synchronization tasks are in queues, should wait for them to finish.
	WaitForSynchronization ModuleRunPhase = "WaitForSynchronization"
	// EnableScheduleBindings - enable schedule binding after Synchronization.
	EnableScheduleBindings ModuleRunPhase = "EnableScheduleBindings"
	// CanRunHelm - module is ready to run its Helm chart.
	CanRunHelm ModuleRunPhase = "CanRunHelm"
	// HooksDisabled - module has its hooks disabled (before update or deletion).
	HooksDisabled ModuleRunPhase = "HooksDisabled"
)

type SynchronizationState

type SynchronizationState struct {
	// contains filtered or unexported fields
}

SynchronizationState stores state to track synchronization tasks for kubernetes bindings either for all global hooks or for module's hooks.

func NewSynchronizationState

func NewSynchronizationState() *SynchronizationState

func (*SynchronizationState) DebugDumpState

func (s *SynchronizationState) DebugDumpState(logEntry *log.Entry)

func (*SynchronizationState) DoneForBinding

func (s *SynchronizationState) DoneForBinding(id string)

func (*SynchronizationState) HasQueued

func (s *SynchronizationState) HasQueued() bool

func (*SynchronizationState) IsComplete

func (s *SynchronizationState) IsComplete() bool

IsComplete returns true if all states are in done status.

func (*SynchronizationState) QueuedForBinding

func (s *SynchronizationState) QueuedForBinding(metadata task.HookMetadata)

type ValuesStorage

type ValuesStorage struct {
	// contains filtered or unexported fields
}

ValuesStorage keeps Module's values in order

func NewValuesStorage

func NewValuesStorage(moduleName string, staticValues utils.Values, validator validator) *ValuesStorage

NewValuesStorage build a new storage for module values

staticValues - values from /modules/<module-name>/values.yaml, which couldn't be reloaded during the runtime

func (*ValuesStorage) CommitValues

func (vs *ValuesStorage) CommitValues() error

CommitValues apply all patches and create up-to-date values for module

func (*ValuesStorage) GenerateNewConfigValues

func (vs *ValuesStorage) GenerateNewConfigValues(configV utils.Values, validate bool) (utils.Values, error)

GenerateNewConfigValues generated new config values, based on static and config values. Additionally, if validate is true, it validates two versions of resulting values: original (without openapi defaults) and with openapi defaults for consistency. this method always makes a copy of the result values to prevent pointers shallow copying

func (*ValuesStorage) GetConfigValues

func (vs *ValuesStorage) GetConfigValues(withPrefix bool) utils.Values

GetConfigValues returns only user defined values

func (*ValuesStorage) GetValues

func (vs *ValuesStorage) GetValues(withPrefix bool) utils.Values

GetValues return current values with applied patches withPrefix means, that values will be returned with module name prefix example:

without prefix:

```yaml
replicas: 1
foo:
  bar: hello-world
```

with prefix:

```yaml
mySuperModule:
	replicas: 1
	foo:
	  bar: hello-world
```

func (*ValuesStorage) SaveConfigValues

func (vs *ValuesStorage) SaveConfigValues(configV utils.Values)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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