Documentation ¶
Index ¶
- Constants
- Variables
- func CreateEmptyWritableFile(filePath string) error
- func GetGlobalHookConfigSchema(version string) *spec.Schema
- func GetModuleHookConfigSchema(version string) *spec.Schema
- func LoadCommonStaticValues(modulesDirs string) (utils.Values, error)
- func MergeLayers(initial utils.Values, layers ...interface{}) utils.Values
- func NewHookConfigFromGoConfig(input *go_hook.HookConfig) (config.HookConfig, error)
- func ReadOpenAPIFiles(openApiDir string) (configSchemaBytes, valuesSchemaBytes []byte, err error)
- type AfterAllConfig
- type AfterDeleteHelmConfig
- type AfterHelmConfig
- type ApplyDefaultsForGlobal
- type ApplyDefaultsForModule
- type BeforeAllConfig
- type BeforeHelmConfig
- type CommonHook
- func (h *CommonHook) GetGoHook() go_hook.GoHook
- func (h *CommonHook) GetName() string
- func (h *CommonHook) GetPath() string
- func (h *CommonHook) ShouldEnableSchedulesOnStartup() bool
- func (h *CommonHook) SynchronizationNeeded() bool
- func (h *CommonHook) WithGoHook(gh go_hook.GoHook)
- func (h *CommonHook) WithModuleManager(moduleManager *ModuleManager)
- type DirectoryConfig
- type GlobalHook
- func (h *GlobalHook) GetConfigDescription() string
- func (h *GlobalHook) GetConfigValues() utils.Values
- func (h *GlobalHook) GetValues() (utils.Values, error)
- func (h *GlobalHook) Order(binding BindingType) float64
- func (h *GlobalHook) PrepareTmpFilesForHookRun(bindingContext []byte) (tmpFiles map[string]string, err error)
- func (h *GlobalHook) Run(bindingType BindingType, bindingContext []BindingContext, ...) error
- func (h *GlobalHook) WithConfig(configOutput []byte) (err error)
- func (h *GlobalHook) WithGoConfig(config *go_hook.HookConfig) (err error)
- type GlobalHookConfig
- func (c *GlobalHookConfig) Bindings() []BindingType
- func (c *GlobalHookConfig) BindingsCount() int
- func (c *GlobalHookConfig) ConvertAfterAll(value interface{}) (*AfterAllConfig, error)
- func (c *GlobalHookConfig) ConvertAndCheck(data []byte) error
- func (c *GlobalHookConfig) ConvertAndCheckV0() (err error)
- func (c *GlobalHookConfig) ConvertAndCheckV1() (err error)
- func (c *GlobalHookConfig) ConvertBeforeAll(value interface{}) (*BeforeAllConfig, error)
- func (c *GlobalHookConfig) HasBinding(binding BindingType) bool
- func (c *GlobalHookConfig) LoadAndValidate(data []byte) error
- type GlobalHookConfigV0
- type Hook
- type HookExecutor
- func (e *HookExecutor) Config() (configOutput []byte, err error)
- func (e *HookExecutor) Run() (result *HookResult, err error)
- func (e *HookExecutor) RunGoHook() (result *HookResult, err error)
- func (e *HookExecutor) WithHelm(helm *helm.ClientFactory)
- func (e *HookExecutor) WithLogLabels(logLabels map[string]string)
- type HookResult
- type KubeConfigManager
- type KubernetesBindingSynchronizationState
- type Module
- func (m *Module) ConfigValues() utils.Values
- func (m *Module) Delete(logLabels map[string]string) error
- func (m *Module) HasKubernetesHooks() bool
- func (m *Module) PrepareValuesYamlFile() (string, error)
- func (m *Module) Run(logLabels map[string]string) (bool, error)
- func (m *Module) RunOnStartup(logLabels map[string]string) error
- func (m *Module) SafeName() string
- func (m *Module) ShouldRunHelmUpgrade(helmClient client.HelmClient, releaseName string, checksum string, ...) (bool, error)
- func (m *Module) StaticAndConfigValues() utils.Values
- func (m *Module) StaticAndNewValues(newValues utils.Values) utils.Values
- func (m *Module) SynchronizationNeeded() bool
- func (m *Module) Values() (utils.Values, error)
- func (m *Module) ValuesForEnabledScript(precedingEnabledModules []string) (utils.Values, error)
- func (m *Module) ValuesKey() string
- func (m *Module) WithHelm(helm *helm.ClientFactory)
- func (m *Module) WithMetricStorage(mstor *metric_storage.MetricStorage)
- func (m *Module) WithModuleManager(moduleManager *ModuleManager)
- type ModuleHook
- func (h *ModuleHook) GetConfigDescription() string
- func (h *ModuleHook) GetConfigValues() utils.Values
- func (h *ModuleHook) GetValues() (utils.Values, error)
- func (h *ModuleHook) Order(binding BindingType) float64
- func (h *ModuleHook) PrepareTmpFilesForHookRun(bindingContext []byte) (tmpFiles map[string]string, err error)
- func (h *ModuleHook) Run(bindingType BindingType, context []BindingContext, logLabels map[string]string, ...) error
- func (h *ModuleHook) WithConfig(configOutput []byte) (err error)
- func (h *ModuleHook) WithGoConfig(config *go_hook.HookConfig) (err error)
- func (h *ModuleHook) WithModule(module *Module)
- type ModuleHookConfig
- func (c *ModuleHookConfig) Bindings() []BindingType
- func (c *ModuleHookConfig) BindingsCount() int
- func (c *ModuleHookConfig) ConvertAfterDeleteHelm(value interface{}) (*AfterDeleteHelmConfig, error)
- func (c *ModuleHookConfig) ConvertAfterHelm(value interface{}) (*AfterHelmConfig, error)
- func (c *ModuleHookConfig) ConvertAndCheck(data []byte) error
- func (c *ModuleHookConfig) ConvertAndCheckV0() (err error)
- func (c *ModuleHookConfig) ConvertAndCheckV1() (err error)
- func (c *ModuleHookConfig) ConvertBeforeHelm(value interface{}) (*BeforeHelmConfig, error)
- func (c *ModuleHookConfig) HasBinding(binding BindingType) bool
- func (c *ModuleHookConfig) LoadAndValidate(data []byte) error
- type ModuleHookConfigV0
- type ModuleManager
- func (mm *ModuleManager) ApplyBindingActions(moduleHook *ModuleHook, bindingActions []go_hook.BindingAction) error
- func (mm *ModuleManager) ApplyEnabledPatch(enabledPatch utils.ValuesPatch) error
- func (mm *ModuleManager) ApplyModuleDynamicValuesPatches(moduleName string, values utils.Values) (utils.Values, error)
- func (mm *ModuleManager) DeleteModule(moduleName string, logLabels map[string]string) error
- func (mm *ModuleManager) DisableModuleHooks(moduleName string)
- func (mm *ModuleManager) DumpDynamicEnabled() string
- func (mm *ModuleManager) DynamicEnabledChecksum() string
- func (mm *ModuleManager) EnableModuleScheduleBindings(moduleName string)
- func (mm *ModuleManager) GetEnabledModuleNames() []string
- func (mm *ModuleManager) GetGlobalHook(name string) *GlobalHook
- func (mm *ModuleManager) GetGlobalHooksInOrder(bindingType BindingType) []string
- func (mm *ModuleManager) GetGlobalHooksNames() []string
- func (mm *ModuleManager) GetKubeConfigValid() bool
- func (mm *ModuleManager) GetModule(name string) *Module
- func (mm *ModuleManager) GetModuleHook(name string) *ModuleHook
- func (mm *ModuleManager) GetModuleHookNames(moduleName string) []string
- func (mm *ModuleManager) GetModuleHooksInOrder(moduleName string, bindingType BindingType) []string
- func (mm *ModuleManager) GetModuleNames() []string
- func (mm *ModuleManager) GetValuesValidator() *validation.ValuesValidator
- func (mm *ModuleManager) GlobalConfigValues() utils.Values
- func (mm *ModuleManager) GlobalStaticAndConfigValues() utils.Values
- func (mm *ModuleManager) GlobalStaticAndNewValues(newValues utils.Values) utils.Values
- func (mm *ModuleManager) GlobalSynchronizationNeeded() bool
- func (mm *ModuleManager) GlobalSynchronizationState() *SynchronizationState
- func (mm *ModuleManager) GlobalValues() (utils.Values, error)
- func (mm *ModuleManager) GlobalValuesPatches() []utils.ValuesPatch
- func (mm *ModuleManager) HandleGlobalEnableKubernetesBindings(hookName string, ...) error
- func (mm *ModuleManager) HandleKubeEvent(kubeEvent KubeEvent, ...)
- func (mm *ModuleManager) HandleModuleEnableKubernetesBindings(moduleName string, ...) error
- func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *kube_config_manager.KubeConfig) (*ModulesState, error)
- func (mm *ModuleManager) HandleScheduleEvent(crontab string, ...) error
- func (mm *ModuleManager) Init() error
- func (mm *ModuleManager) IsModuleEnabled(moduleName string) bool
- func (mm *ModuleManager) LoopByBinding(binding BindingType, fn func(gh *GlobalHook, m *Module, mh *ModuleHook))
- func (mm *ModuleManager) ModuleConfigValues(moduleName string) utils.Values
- func (mm *ModuleManager) ModuleDynamicValuesPatches(moduleName string) []utils.ValuesPatch
- func (mm *ModuleManager) RefreshEnabledState(logLabels map[string]string) (*ModulesState, error)
- func (mm *ModuleManager) RefreshStateFromHelmReleases(logLabels map[string]string) (*ModulesState, error)
- func (mm *ModuleManager) RegisterGlobalHooks() error
- func (mm *ModuleManager) RegisterModuleHooks(module *Module, logLabels map[string]string) error
- func (mm *ModuleManager) RegisterModules() error
- func (mm *ModuleManager) RunGlobalHook(hookName string, binding BindingType, bindingContext []BindingContext, ...) (string, string, error)
- func (mm *ModuleManager) RunModule(moduleName string, logLabels map[string]string) (bool, error)
- func (mm *ModuleManager) RunModuleHook(hookName string, binding BindingType, bindingContext []BindingContext, ...) (beforeChecksum string, afterChecksum string, err error)
- func (mm *ModuleManager) SetKubeConfigValid(valid bool)
- func (mm *ModuleManager) SetKubeConfigValuesValid(valid bool)
- func (mm *ModuleManager) Start()
- func (mm *ModuleManager) Stop()
- func (mm *ModuleManager) UpdateGlobalConfigValues(configValues utils.Values)
- func (mm *ModuleManager) UpdateGlobalDynamicValuesPatches(valuesPatch utils.ValuesPatch)
- func (mm *ModuleManager) UpdateModuleConfigValues(moduleName string, configValues utils.Values)
- func (mm *ModuleManager) UpdateModuleDynamicValuesPatches(moduleName string, valuesPatch utils.ValuesPatch)
- type ModuleManagerDependencies
- type ModuleRunPhase
- type ModuleSet
- type ModuleState
- type ModulesState
- type SynchronizationState
- type ValuesTransform
- type ValuesTransformer
Constants ¶
const ( PathsSeparator = ":" ValuesFileName = "values.yaml" )
const ( ModuleOrderIdx = 2 ModuleNameIdx = 3 )
Variables ¶
var ValidModuleNameRe = regexp.MustCompile(`^(([0-9]+)-)?(.+)$`)
ValidModuleNameRe defines a valid module name. It may have a number prefix: it is an order of the module.
Functions ¶
func CreateEmptyWritableFile ¶
func LoadCommonStaticValues ¶ added in v1.1.3
LoadCommonStaticValues finds values.yaml files in all specified directories.
func NewHookConfigFromGoConfig ¶
func NewHookConfigFromGoConfig(input *go_hook.HookConfig) (config.HookConfig, error)
func ReadOpenAPIFiles ¶
ReadOpenAPIFiles reads config-values.yaml and values.yaml from the specified directory. Global schemas:
/global/openapi/config-values.yaml /global/openapi/values.yaml
Module schemas:
/modules/XXX-module-name/openapi/config-values.yaml /modules/XXX-module-name/openapi/values.yaml
Types ¶
type AfterAllConfig ¶
type AfterAllConfig struct { CommonBindingConfig Order float64 }
type AfterDeleteHelmConfig ¶
type AfterDeleteHelmConfig struct { CommonBindingConfig Order float64 }
type AfterHelmConfig ¶
type AfterHelmConfig struct { CommonBindingConfig Order float64 }
type ApplyDefaultsForGlobal ¶
type ApplyDefaultsForGlobal struct { SchemaType validation.SchemaType ValuesValidator *validation.ValuesValidator }
type ApplyDefaultsForModule ¶
type ApplyDefaultsForModule struct { ModuleValuesKey string SchemaType validation.SchemaType ValuesValidator *validation.ValuesValidator }
type BeforeAllConfig ¶
type BeforeAllConfig struct { CommonBindingConfig Order float64 }
type BeforeHelmConfig ¶
type BeforeHelmConfig struct { CommonBindingConfig Order float64 }
type CommonHook ¶
type CommonHook struct { hook.Hook GoHook go_hook.GoHook // contains filtered or unexported fields }
func (*CommonHook) GetGoHook ¶
func (h *CommonHook) GetGoHook() go_hook.GoHook
func (*CommonHook) GetName ¶
func (h *CommonHook) GetName() string
func (*CommonHook) GetPath ¶
func (h *CommonHook) GetPath() string
func (*CommonHook) ShouldEnableSchedulesOnStartup ¶ added in v1.0.6
func (h *CommonHook) ShouldEnableSchedulesOnStartup() bool
ShouldEnableSchedulesOnStartup returns true for Go hooks if EnableSchedulesOnStartup is set. This flag for schedule hooks that start after onStartup hooks.
func (*CommonHook) SynchronizationNeeded ¶
func (h *CommonHook) SynchronizationNeeded() bool
SynchronizationNeeded is true if there is binding with executeHookOnSynchronization.
func (*CommonHook) WithGoHook ¶
func (h *CommonHook) WithGoHook(gh go_hook.GoHook)
func (*CommonHook) WithModuleManager ¶
func (h *CommonHook) WithModuleManager(moduleManager *ModuleManager)
type DirectoryConfig ¶ added in v1.1.3
DirectoryConfig configures directories for ModuleManager
type GlobalHook ¶
type GlobalHook struct { *CommonHook Config *GlobalHookConfig }
func NewGlobalHook ¶
func NewGlobalHook(name, path string) *GlobalHook
func SearchGlobalGoHooks ¶
func SearchGlobalGoHooks() (hooks []*GlobalHook, err error)
func SearchGlobalHooks ¶
func SearchGlobalHooks(hooksDir string) (hooks []*GlobalHook, err error)
SearchGlobalHooks recursively find all executables in hooksDir. Absent hooksDir is not an error.
func SearchGlobalShellHooks ¶
func SearchGlobalShellHooks(hooksDir string) (hooks []*GlobalHook, err error)
SearchGlobalHooks recursively find all executables in hooksDir. Absent hooksDir is not an error.
func (*GlobalHook) GetConfigDescription ¶
func (h *GlobalHook) GetConfigDescription() string
func (*GlobalHook) GetConfigValues ¶
func (h *GlobalHook) GetConfigValues() utils.Values
func (*GlobalHook) Order ¶
func (h *GlobalHook) Order(binding BindingType) float64
Order return float order number for bindings with order.
func (*GlobalHook) PrepareTmpFilesForHookRun ¶
func (h *GlobalHook) PrepareTmpFilesForHookRun(bindingContext []byte) (tmpFiles map[string]string, err error)
PrepareTmpFilesForHookRun creates temporary files for hook and returns environment variables with paths
func (*GlobalHook) Run ¶
func (h *GlobalHook) Run(bindingType BindingType, bindingContext []BindingContext, logLabels map[string]string) error
func (*GlobalHook) WithConfig ¶
func (h *GlobalHook) WithConfig(configOutput []byte) (err error)
func (*GlobalHook) WithGoConfig ¶
func (h *GlobalHook) WithGoConfig(config *go_hook.HookConfig) (err error)
type GlobalHookConfig ¶
type GlobalHookConfig struct { config.HookConfig // versioned raw config values GlobalV0 *GlobalHookConfigV0 GlobalV1 *GlobalHookConfigV0 // effective config values BeforeAll *BeforeAllConfig AfterAll *AfterAllConfig }
GlobalHookConfig is a structure with versioned hook configuration
func NewGlobalHookConfigFromGoConfig ¶
func NewGlobalHookConfigFromGoConfig(input *go_hook.HookConfig) (*GlobalHookConfig, error)
func (*GlobalHookConfig) Bindings ¶
func (c *GlobalHookConfig) Bindings() []BindingType
func (*GlobalHookConfig) BindingsCount ¶
func (c *GlobalHookConfig) BindingsCount() int
func (*GlobalHookConfig) ConvertAfterAll ¶
func (c *GlobalHookConfig) ConvertAfterAll(value interface{}) (*AfterAllConfig, error)
func (*GlobalHookConfig) ConvertAndCheck ¶
func (c *GlobalHookConfig) ConvertAndCheck(data []byte) error
func (*GlobalHookConfig) ConvertAndCheckV0 ¶
func (c *GlobalHookConfig) ConvertAndCheckV0() (err error)
func (*GlobalHookConfig) ConvertAndCheckV1 ¶
func (c *GlobalHookConfig) ConvertAndCheckV1() (err error)
func (*GlobalHookConfig) ConvertBeforeAll ¶
func (c *GlobalHookConfig) ConvertBeforeAll(value interface{}) (*BeforeAllConfig, error)
func (*GlobalHookConfig) HasBinding ¶
func (c *GlobalHookConfig) HasBinding(binding BindingType) bool
func (*GlobalHookConfig) LoadAndValidate ¶
func (c *GlobalHookConfig) LoadAndValidate(data []byte) error
LoadAndValidate loads config from bytes and validate it. Returns multierror.
type GlobalHookConfigV0 ¶
type GlobalHookConfigV0 struct { BeforeAll interface{} `json:"beforeAll"` AfterAll interface{} `json:"afterAll"` }
type Hook ¶
type Hook interface { WithModuleManager(moduleManager *ModuleManager) WithConfig(configOutput []byte) (err error) WithGoConfig(config *go_hook.HookConfig) (err error) WithHookController(hookController controller.HookController) GetName() string GetPath() string GetGoHook() go_hook.GoHook GetValues() (utils.Values, error) GetConfigValues() utils.Values PrepareTmpFilesForHookRun(bindingContext []byte) (map[string]string, error) Order(binding sh_op_types.BindingType) float64 }
type HookExecutor ¶
type HookExecutor struct { Hook Hook Context []BindingContext ConfigVersion string ConfigValuesPath string ValuesPath string ContextPath string ConfigValuesPatchPath string ValuesPatchPath string MetricsPath string ObjectPatcher *object_patch.ObjectPatcher KubernetesPatchPath string LogLabels map[string]string Helm *helm.ClientFactory }
func NewHookExecutor ¶
func NewHookExecutor(h Hook, context []BindingContext, configVersion string, objectPatcher *object_patch.ObjectPatcher) *HookExecutor
func (*HookExecutor) Config ¶
func (e *HookExecutor) Config() (configOutput []byte, err error)
func (*HookExecutor) Run ¶
func (e *HookExecutor) Run() (result *HookResult, err error)
func (*HookExecutor) RunGoHook ¶
func (e *HookExecutor) RunGoHook() (result *HookResult, err error)
func (*HookExecutor) WithHelm ¶ added in v1.0.6
func (e *HookExecutor) WithHelm(helm *helm.ClientFactory)
func (*HookExecutor) WithLogLabels ¶
func (e *HookExecutor) WithLogLabels(logLabels map[string]string)
type HookResult ¶
type HookResult struct { Usage *executor.CmdUsage Patches map[utils.ValuesPatchType]*utils.ValuesPatch Metrics []metric_operation.MetricOperation ObjectPatcherOperations []object_patch.Operation BindingActions []go_hook.BindingAction }
type KubeConfigManager ¶ added in v1.1.3
type KubernetesBindingSynchronizationState ¶
type KubernetesBindingSynchronizationState struct { HookName string BindingName string Queued bool Done bool }
KubernetesBindingSynchronizationState is a state of the single Synchronization task for one kubernetes binding.
func (*KubernetesBindingSynchronizationState) String ¶
func (k *KubernetesBindingSynchronizationState) String() string
type Module ¶
type Module struct { Name string // MODULE_NAME env Path string // MODULE_DIR env Order int // MODULE_ORDER env // module values from modules/values.yaml file CommonStaticConfig *utils.ModuleConfig // module values from modules/<module name>/values.yaml StaticConfig *utils.ModuleConfig State *ModuleState // contains filtered or unexported fields }
func (*Module) ConfigValues ¶
ConfigValues returns raw values from ConfigMap: - global section - module section
func (*Module) Delete ¶
Delete removes helm release if it exists and runs afterDeleteHelm hooks. It is a handler for MODULE_DELETE task.
func (*Module) HasKubernetesHooks ¶ added in v1.0.5
HasKubernetesHooks is true if module has at least one kubernetes hook.
func (*Module) PrepareValuesYamlFile ¶
values.yaml for helm
func (*Module) Run ¶
Run is a phase of module lifecycle that runs onStartup and beforeHelm hooks, helm upgrade --install command and afterHelm hook. It is a handler of task MODULE_RUN
func (*Module) RunOnStartup ¶
RunOnStartup is a phase of module lifecycle that runs onStartup hooks. It is a handler of task MODULE_RUN
func (*Module) ShouldRunHelmUpgrade ¶
func (m *Module) ShouldRunHelmUpgrade(helmClient client.HelmClient, releaseName string, checksum string, manifests []manifest.Manifest, logLabels map[string]string) (bool, error)
ShouldRunHelmUpgrade tells if there is a case to run `helm upgrade`:
- Helm chart in not installed yet.
- Last release has FAILED status.
- Checksum in release values not equals to checksum argument.
- Some resources installed previously are missing.
If all these conditions aren't met, helm upgrade can be skipped.
func (*Module) StaticAndConfigValues ¶
StaticAndConfigValues returns global common static values defined in various values.yaml files and in a ConfigMap and module values defined in various values.yaml files and in a ConfigMap.
func (*Module) StaticAndNewValues ¶
StaticAndNewValues returns global values defined in various values.yaml files and in a ConfigMap and module values defined in various values.yaml files merged with newValues.
func (*Module) SynchronizationNeeded ¶
SynchronizationNeeded is true if module has at least one kubernetes hook with executeHookOnSynchronization.
func (*Module) Values ¶
Values returns effective values for module hook or helm chart:
global section: static + config + defaults + patches from hooks
module section: static + config + defaults + patches from hooks
func (*Module) ValuesForEnabledScript ¶
ValuesForEnabledScript returns effective values for enabled script. There is enabledModules key in global section with previously enabled modules.
func (*Module) WithHelm ¶ added in v1.0.6
func (m *Module) WithHelm(helm *helm.ClientFactory)
func (*Module) WithMetricStorage ¶
func (m *Module) WithMetricStorage(mstor *metric_storage.MetricStorage)
func (*Module) WithModuleManager ¶
func (m *Module) WithModuleManager(moduleManager *ModuleManager)
type ModuleHook ¶
type ModuleHook struct { *CommonHook Module *Module Config *ModuleHookConfig }
func NewModuleHook ¶
func NewModuleHook(name, path string) *ModuleHook
func SearchModuleGoHooks ¶
func SearchModuleGoHooks(module *Module) (hooks []*ModuleHook, err error)
func SearchModuleHooks ¶
func SearchModuleHooks(module *Module) (hooks []*ModuleHook, err error)
func SearchModuleShellHooks ¶
func SearchModuleShellHooks(module *Module) (hooks []*ModuleHook, err error)
func (*ModuleHook) GetConfigDescription ¶
func (h *ModuleHook) GetConfigDescription() string
func (*ModuleHook) GetConfigValues ¶
func (h *ModuleHook) GetConfigValues() utils.Values
func (*ModuleHook) Order ¶
func (h *ModuleHook) Order(binding BindingType) float64
Order return float order number for bindings with order.
func (*ModuleHook) PrepareTmpFilesForHookRun ¶
func (h *ModuleHook) PrepareTmpFilesForHookRun(bindingContext []byte) (tmpFiles map[string]string, err error)
PrepareTmpFilesForHookRun creates temporary files for hook and returns environment variables with paths
func (*ModuleHook) WithConfig ¶
func (h *ModuleHook) WithConfig(configOutput []byte) (err error)
func (*ModuleHook) WithGoConfig ¶
func (h *ModuleHook) WithGoConfig(config *go_hook.HookConfig) (err error)
func (*ModuleHook) WithModule ¶
func (h *ModuleHook) WithModule(module *Module)
type ModuleHookConfig ¶
type ModuleHookConfig struct { config.HookConfig // versioned raw config values ModuleV0 *ModuleHookConfigV0 ModuleV1 *ModuleHookConfigV0 // effective config values BeforeHelm *BeforeHelmConfig AfterHelm *AfterHelmConfig AfterDeleteHelm *AfterDeleteHelmConfig }
ModuleHookConfig is a structure with versioned hook configuration
func NewModuleHookConfigFromGoConfig ¶
func NewModuleHookConfigFromGoConfig(input *go_hook.HookConfig) (*ModuleHookConfig, error)
func (*ModuleHookConfig) Bindings ¶
func (c *ModuleHookConfig) Bindings() []BindingType
func (*ModuleHookConfig) BindingsCount ¶
func (c *ModuleHookConfig) BindingsCount() int
func (*ModuleHookConfig) ConvertAfterDeleteHelm ¶
func (c *ModuleHookConfig) ConvertAfterDeleteHelm(value interface{}) (*AfterDeleteHelmConfig, error)
func (*ModuleHookConfig) ConvertAfterHelm ¶
func (c *ModuleHookConfig) ConvertAfterHelm(value interface{}) (*AfterHelmConfig, error)
func (*ModuleHookConfig) ConvertAndCheck ¶
func (c *ModuleHookConfig) ConvertAndCheck(data []byte) error
func (*ModuleHookConfig) ConvertAndCheckV0 ¶
func (c *ModuleHookConfig) ConvertAndCheckV0() (err error)
func (*ModuleHookConfig) ConvertAndCheckV1 ¶
func (c *ModuleHookConfig) ConvertAndCheckV1() (err error)
func (*ModuleHookConfig) ConvertBeforeHelm ¶
func (c *ModuleHookConfig) ConvertBeforeHelm(value interface{}) (*BeforeHelmConfig, error)
func (*ModuleHookConfig) HasBinding ¶
func (c *ModuleHookConfig) HasBinding(binding BindingType) bool
func (*ModuleHookConfig) LoadAndValidate ¶
func (c *ModuleHookConfig) LoadAndValidate(data []byte) error
LoadAndValidate loads config from bytes and validate it. Returns multierror.
type ModuleHookConfigV0 ¶
type ModuleHookConfigV0 struct { BeforeHelm interface{} `json:"beforeHelm"` AfterHelm interface{} `json:"afterHelm"` AfterDeleteHelm interface{} `json:"afterDeleteHelm"` }
type ModuleManager ¶
type ModuleManager struct { // Directories. ModulesDir string GlobalHooksDir string TempDir string ValuesValidator *validation.ValuesValidator // contains filtered or unexported fields }
func NewModuleManager ¶ added in v1.0.6
func NewModuleManager(ctx context.Context, dirCfg DirectoryConfig, deps *ModuleManagerDependencies) *ModuleManager
NewModuleManager returns new MainModuleManager
func (*ModuleManager) ApplyBindingActions ¶ added in v1.1.3
func (mm *ModuleManager) ApplyBindingActions(moduleHook *ModuleHook, bindingActions []go_hook.BindingAction) error
func (*ModuleManager) ApplyEnabledPatch ¶
func (mm *ModuleManager) ApplyEnabledPatch(enabledPatch utils.ValuesPatch) error
ApplyEnabledPatch changes "dynamicEnabled" map with patches.
func (*ModuleManager) ApplyModuleDynamicValuesPatches ¶ added in v1.0.6
func (*ModuleManager) DeleteModule ¶
func (mm *ModuleManager) DeleteModule(moduleName string, logLabels map[string]string) error
TODO: moduleManager.GetModule(modName).Delete()
func (*ModuleManager) DisableModuleHooks ¶
func (mm *ModuleManager) DisableModuleHooks(moduleName string)
func (*ModuleManager) DumpDynamicEnabled ¶ added in v1.1.3
func (mm *ModuleManager) DumpDynamicEnabled() string
func (*ModuleManager) DynamicEnabledChecksum ¶
func (mm *ModuleManager) DynamicEnabledChecksum() string
DynamicEnabledChecksum returns checksum for dynamicEnabled map
func (*ModuleManager) EnableModuleScheduleBindings ¶ added in v1.0.5
func (mm *ModuleManager) EnableModuleScheduleBindings(moduleName string)
func (*ModuleManager) GetEnabledModuleNames ¶ added in v1.0.6
func (mm *ModuleManager) GetEnabledModuleNames() []string
func (*ModuleManager) GetGlobalHook ¶
func (mm *ModuleManager) GetGlobalHook(name string) *GlobalHook
func (*ModuleManager) GetGlobalHooksInOrder ¶
func (mm *ModuleManager) GetGlobalHooksInOrder(bindingType BindingType) []string
func (*ModuleManager) GetGlobalHooksNames ¶ added in v1.0.4
func (mm *ModuleManager) GetGlobalHooksNames() []string
func (*ModuleManager) GetKubeConfigValid ¶ added in v1.0.6
func (mm *ModuleManager) GetKubeConfigValid() bool
func (*ModuleManager) GetModule ¶
func (mm *ModuleManager) GetModule(name string) *Module
func (*ModuleManager) GetModuleHook ¶
func (mm *ModuleManager) GetModuleHook(name string) *ModuleHook
func (*ModuleManager) GetModuleHookNames ¶
func (mm *ModuleManager) GetModuleHookNames(moduleName string) []string
func (*ModuleManager) GetModuleHooksInOrder ¶
func (mm *ModuleManager) GetModuleHooksInOrder(moduleName string, bindingType BindingType) []string
func (*ModuleManager) GetModuleNames ¶ added in v1.1.0
func (mm *ModuleManager) GetModuleNames() []string
func (*ModuleManager) GetValuesValidator ¶ added in v1.1.0
func (mm *ModuleManager) GetValuesValidator() *validation.ValuesValidator
func (*ModuleManager) GlobalConfigValues ¶
func (mm *ModuleManager) GlobalConfigValues() utils.Values
GlobalConfigValues return raw global values only from a ConfigMap.
func (*ModuleManager) GlobalStaticAndConfigValues ¶
func (mm *ModuleManager) GlobalStaticAndConfigValues() utils.Values
GlobalStaticAndConfigValues return global values defined in various values.yaml files and in a ConfigMap
func (*ModuleManager) GlobalStaticAndNewValues ¶
func (mm *ModuleManager) GlobalStaticAndNewValues(newValues utils.Values) utils.Values
GlobalStaticAndNewValues return global values defined in various values.yaml files merged with newValues
func (*ModuleManager) GlobalSynchronizationNeeded ¶
func (mm *ModuleManager) GlobalSynchronizationNeeded() bool
GlobalSynchronizationNeeded is true if there is at least one global kubernetes hook with executeHookOnSynchronization.
func (*ModuleManager) GlobalSynchronizationState ¶ added in v1.0.5
func (mm *ModuleManager) GlobalSynchronizationState() *SynchronizationState
func (*ModuleManager) GlobalValues ¶
func (mm *ModuleManager) GlobalValues() (utils.Values, error)
GlobalValues return current global values with applied patches
func (*ModuleManager) GlobalValuesPatches ¶
func (mm *ModuleManager) GlobalValuesPatches() []utils.ValuesPatch
GlobalValues return patches for global values
func (*ModuleManager) HandleGlobalEnableKubernetesBindings ¶
func (mm *ModuleManager) HandleGlobalEnableKubernetesBindings(hookName string, createTaskFn func(*GlobalHook, controller.BindingExecutionInfo)) error
func (*ModuleManager) HandleKubeEvent ¶
func (mm *ModuleManager) HandleKubeEvent(kubeEvent KubeEvent, createGlobalTaskFn func(*GlobalHook, controller.BindingExecutionInfo), createModuleTaskFn func(*Module, *ModuleHook, controller.BindingExecutionInfo))
func (*ModuleManager) HandleModuleEnableKubernetesBindings ¶
func (mm *ModuleManager) HandleModuleEnableKubernetesBindings(moduleName string, createTaskFn func(*ModuleHook, controller.BindingExecutionInfo)) error
func (*ModuleManager) HandleNewKubeConfig ¶ added in v1.0.6
func (mm *ModuleManager) HandleNewKubeConfig(kubeConfig *kube_config_manager.KubeConfig) (*ModulesState, error)
HandleNewKubeConfig validates new config values with config schemas, checks which parts changed and returns state with AllEnabledModules and ModulesToReload list if only module sections are changed. It returns a nil state if new KubeConfig not changing config values or 'enabled by config' state.
This method updates 'config values' caches: - mm.enabledModulesByConfig - mm.kubeGlobalConfigValues - mm.kubeModulesConfigValues
func (*ModuleManager) HandleScheduleEvent ¶
func (mm *ModuleManager) HandleScheduleEvent(crontab string, createGlobalTaskFn func(*GlobalHook, controller.BindingExecutionInfo), createModuleTaskFn func(*Module, *ModuleHook, controller.BindingExecutionInfo)) error
func (*ModuleManager) IsModuleEnabled ¶ added in v1.0.6
func (mm *ModuleManager) IsModuleEnabled(moduleName string) bool
func (*ModuleManager) LoopByBinding ¶ added in v1.1.3
func (mm *ModuleManager) LoopByBinding(binding BindingType, fn func(gh *GlobalHook, m *Module, mh *ModuleHook))
func (*ModuleManager) ModuleConfigValues ¶ added in v1.0.6
func (mm *ModuleManager) ModuleConfigValues(moduleName string) utils.Values
ModuleConfigValues returns config values for module.
func (*ModuleManager) ModuleDynamicValuesPatches ¶ added in v1.0.6
func (mm *ModuleManager) ModuleDynamicValuesPatches(moduleName string) []utils.ValuesPatch
ModuleConfigValues returns all patches for dynamic values.
func (*ModuleManager) RefreshEnabledState ¶ added in v1.0.6
func (mm *ModuleManager) RefreshEnabledState(logLabels map[string]string) (*ModulesState, error)
RefreshEnabledState runs enabled hooks for all 'enabled by config' modules and calculates new arrays of enabled modules. It returns ModulesState with lists of modules to disable and enable.
This method is called after beforeAll hooks to take into account possible changes to 'dynamic enabled'.
This method updates caches: - mm.enabledModules
func (*ModuleManager) RefreshStateFromHelmReleases ¶ added in v1.0.6
func (mm *ModuleManager) RefreshStateFromHelmReleases(logLabels map[string]string) (*ModulesState, error)
RefreshStateFromHelmReleases retrieves all Helm releases. It treats releases for known modules as an initial list of enabled modules. Run this method once at startup.
func (*ModuleManager) RegisterGlobalHooks ¶ added in v1.1.3
func (mm *ModuleManager) RegisterGlobalHooks() error
func (*ModuleManager) RegisterModuleHooks ¶
func (mm *ModuleManager) RegisterModuleHooks(module *Module, logLabels map[string]string) error
func (*ModuleManager) RegisterModules ¶ added in v1.1.3
func (mm *ModuleManager) RegisterModules() error
RegisterModules load all available modules from modules directory.
func (*ModuleManager) RunGlobalHook ¶
func (*ModuleManager) RunModule ¶
RunModule runs beforeHelm hook, helm upgrade --install and afterHelm or afterDeleteHelm hook
func (*ModuleManager) RunModuleHook ¶
func (*ModuleManager) SetKubeConfigValid ¶ added in v1.0.6
func (mm *ModuleManager) SetKubeConfigValid(valid bool)
func (*ModuleManager) SetKubeConfigValuesValid ¶ added in v1.1.3
func (mm *ModuleManager) SetKubeConfigValuesValid(valid bool)
func (*ModuleManager) Stop ¶ added in v1.1.3
func (mm *ModuleManager) Stop()
func (*ModuleManager) UpdateGlobalConfigValues ¶ added in v1.0.2
func (mm *ModuleManager) UpdateGlobalConfigValues(configValues utils.Values)
UpdateGlobalConfigValues sets updated global config values.
func (*ModuleManager) UpdateGlobalDynamicValuesPatches ¶ added in v1.0.2
func (mm *ModuleManager) UpdateGlobalDynamicValuesPatches(valuesPatch utils.ValuesPatch)
UpdateGlobalDynamicValuesPatches appends patches for global dynamic values.
func (*ModuleManager) UpdateModuleConfigValues ¶ added in v1.0.2
func (mm *ModuleManager) UpdateModuleConfigValues(moduleName string, configValues utils.Values)
UpdateModuleConfigValues sets updated config values for module.
func (*ModuleManager) UpdateModuleDynamicValuesPatches ¶ added in v1.0.2
func (mm *ModuleManager) UpdateModuleDynamicValuesPatches(moduleName string, valuesPatch utils.ValuesPatch)
UpdateModuleDynamicValuesPatches appends patches for dynamic values for module.
type ModuleManagerDependencies ¶ added in v1.1.3
type ModuleManagerDependencies struct { KubeObjectPatcher *object_patch.ObjectPatcher KubeEventsManager kube_events_manager.KubeEventsManager KubeConfigManager KubeConfigManager ScheduleManager schedule_manager.ScheduleManager Helm *helm.ClientFactory HelmResourcesManager helm_resources_manager.HelmResourcesManager MetricStorage *metric_storage.MetricStorage HookMetricStorage *metric_storage.MetricStorage }
ModuleManagerDependencies pass dependencies for ModuleManager
type ModuleRunPhase ¶ added in v1.0.5
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" )
type ModuleSet ¶ added in v1.1.3
type ModuleSet struct {
// contains filtered or unexported fields
}
func SearchModules ¶
func (*ModuleSet) NamesInOrder ¶ added in v1.1.3
type ModuleState ¶
type ModuleState struct { Enabled bool Phase ModuleRunPhase LastModuleErr error // contains filtered or unexported fields }
func NewModuleState ¶ added in v1.0.5
func NewModuleState() *ModuleState
func (*ModuleState) GetLastHookErr ¶ added in v1.1.0
func (s *ModuleState) GetLastHookErr() error
GetLastHookErr returns hook error.
func (*ModuleState) SetLastHookErr ¶ added in v1.1.0
func (s *ModuleState) SetLastHookErr(hookName string, err error)
SetLastHookErr saves error from hook.
func (*ModuleState) Synchronization ¶ added in v1.0.5
func (s *ModuleState) Synchronization() *SynchronizationState
type ModulesState ¶
type ModulesState struct { // All enabled modules. AllEnabledModules []string // Modules that should be deleted. ModulesToDisable []string // Modules that was disabled and now are enabled. ModulesToEnable []string // Modules changed after ConfigMap changes ModulesToReload []string // Helm releases without module directory (unknown modules). ModulesToPurge []string }
ModulesState determines which modules should be enabled, disabled or reloaded.
type SynchronizationState ¶ added in v1.0.5
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 ¶ added in v1.0.5
func NewSynchronizationState() *SynchronizationState
func (*SynchronizationState) DebugDumpState ¶ added in v1.0.5
func (s *SynchronizationState) DebugDumpState(logEntry *log.Entry)
func (*SynchronizationState) DoneForBinding ¶ added in v1.0.5
func (s *SynchronizationState) DoneForBinding(id string)
func (*SynchronizationState) HasQueued ¶ added in v1.0.5
func (s *SynchronizationState) HasQueued() bool
func (*SynchronizationState) IsComplete ¶ added in v1.0.5
func (s *SynchronizationState) IsComplete() bool
IsComplete returns true if all states are in done status.
func (*SynchronizationState) QueuedForBinding ¶ added in v1.0.5
func (s *SynchronizationState) QueuedForBinding(metadata task.HookMetadata)