Documentation ¶
Index ¶
- Variables
- func CreateEmptyWritableFile(filePath string) error
- func GetGlobalHookConfigSchema(version string) *spec.Schema
- func GetModuleHookConfigSchema(version string) *spec.Schema
- func NewMainModuleManager() *moduleManager
- type AfterAllConfig
- type AfterDeleteHelmConfig
- type AfterHelmConfig
- type BeforeAllConfig
- type BeforeHelmConfig
- type ChangeType
- type CommonHook
- type Event
- type EventType
- type GlobalHook
- func (gh *GlobalHook) GetConfigDescription() string
- func (g *GlobalHook) Order(binding BindingType) float64
- func (h *GlobalHook) PrepareTmpFilesForHookRun(bindingContext []byte) (tmpFiles map[string]string, err error)
- func (h *GlobalHook) Run(bindingType BindingType, context []BindingContext, logLabels map[string]string) error
- func (g *GlobalHook) WithConfig(configOutput []byte) (err error)
- type GlobalHookConfig
- func (c *GlobalHookConfig) Bindings() []BindingType
- 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
- type Module
- func (m *Module) ConfigValues() utils.Values
- func (m *Module) Delete(logLabels map[string]string) error
- func (m *Module) Run(onStartup bool, logLabels map[string]string, afterStartupCb func() error) (bool, error)
- func (m *Module) SafeName() string
- func (m *Module) ShouldRunHelmUpgrade(helmClient helm.HelmClient, releaseName string, checksum string, ...) (bool, error)
- func (m *Module) Values() (utils.Values, error)
- func (m *Module) ValuesKey() string
- func (m *Module) ValuesPatches() []utils.ValuesPatch
- func (m *Module) WithModuleManager(moduleManager *moduleManager)
- type ModuleChange
- type ModuleHook
- func (m *ModuleHook) GetConfigDescription() string
- func (m *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 (m *ModuleHook) WithConfig(configOutput []byte) (err error)
- func (m *ModuleHook) WithModule(module *Module)
- type ModuleHookConfig
- func (c *ModuleHookConfig) Bindings() []BindingType
- 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
- type ModulesState
Constants ¶
This section is empty.
Variables ¶
var ValidModuleNameRe = regexp.MustCompile(`^[0-9][0-9][0-9]-(.*)$`)
Functions ¶
func CreateEmptyWritableFile ¶
func NewMainModuleManager ¶
func NewMainModuleManager() *moduleManager
NewMainModuleManager returns new MainModuleManager
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 BeforeAllConfig ¶
type BeforeAllConfig struct { CommonBindingConfig Order float64 }
type BeforeHelmConfig ¶
type BeforeHelmConfig struct { CommonBindingConfig Order float64 }
type ChangeType ¶
type ChangeType string
ChangeType are types of module changes.
const ( // All other types are deprecated. This const can be removed in future versions. // Module values are changed Changed ChangeType = "MODULE_CHANGED" )
type CommonHook ¶
func (*CommonHook) GetName ¶
func (h *CommonHook) GetName() string
func (*CommonHook) GetPath ¶
func (h *CommonHook) GetPath() string
func (*CommonHook) WithModuleManager ¶
func (c *CommonHook) WithModuleManager(moduleManager *moduleManager)
type Event ¶
type Event struct { ModulesChanges []ModuleChange Type EventType }
Event is used to send module events to the main loop.
type GlobalHook ¶
type GlobalHook struct { *CommonHook Config *GlobalHookConfig }
func NewGlobalHook ¶
func NewGlobalHook(name, path string) *GlobalHook
func SearchGlobalHooks ¶
func SearchGlobalHooks(hooksDir string) (hooks []*GlobalHook, err error)
SearchGlobalHooks recursively find all executables in hooksDir. Absent hooksDir is not an error.
func (*GlobalHook) GetConfigDescription ¶
func (gh *GlobalHook) GetConfigDescription() string
func (*GlobalHook) Order ¶
func (g *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, context []BindingContext, logLabels map[string]string) error
func (*GlobalHook) WithConfig ¶
func (g *GlobalHook) WithConfig(configOutput []byte) (err error)
type GlobalHookConfig ¶
type GlobalHookConfig struct { hook_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 (*GlobalHookConfig) Bindings ¶
func (c *GlobalHookConfig) Bindings() []BindingType
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) WithHookController(hookController controller.HookController) GetHookController() controller.HookController GetName() string GetPath() string PrepareTmpFilesForHookRun(bindingContext []byte) (map[string]string, error) Order(binding BindingType) float64 }
type HookExecutor ¶
type HookExecutor struct { Hook Hook Context BindingContextList ConfigValuesPath string ValuesPath string ContextPath string ConfigValuesPatchPath string ValuesPatchPath string MetricsPath string LogLabels map[string]string }
func NewHookExecutor ¶
func NewHookExecutor(h Hook, context BindingContextList) *HookExecutor
func (*HookExecutor) Config ¶
func (e *HookExecutor) Config() (configOutput []byte, err error)
func (*HookExecutor) Run ¶
func (e *HookExecutor) Run() (patches map[utils.ValuesPatchType]*utils.ValuesPatch, metrics []metrics_storage.MetricOperation, err error)
func (*HookExecutor) WithLogLabels ¶
func (e *HookExecutor) WithLogLabels(logLabels map[string]string)
type Module ¶
type Module struct { Name string Path string // module values from modules/values.yaml file CommonStaticConfig *utils.ModuleConfig // module values from modules/<module name>/values.yaml StaticConfig *utils.ModuleConfig LastReleaseManifests []manifest.Manifest // contains filtered or unexported fields }
func SearchModules ¶
func (*Module) ConfigValues ¶
ConfigValues returns values from ConfigMap: global section and 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) Run ¶
func (m *Module) Run(onStartup bool, logLabels map[string]string, afterStartupCb func() error) (bool, error)
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) ShouldRunHelmUpgrade ¶
func (*Module) Values ¶
values returns merged values for hooks. There is enabledModules key in global section with all enabled modules.
func (*Module) ValuesPatches ¶
func (m *Module) ValuesPatches() []utils.ValuesPatch
func (*Module) WithModuleManager ¶
func (m *Module) WithModuleManager(moduleManager *moduleManager)
type ModuleChange ¶
type ModuleChange struct { Name string ChangeType ChangeType }
ModuleChange contains module name and type of module changes.
type ModuleHook ¶
type ModuleHook struct { *CommonHook Module *Module Config *ModuleHookConfig }
func NewModuleHook ¶
func NewModuleHook(name, path string) *ModuleHook
func SearchModuleHooks ¶
func SearchModuleHooks(module *Module) (hooks []*ModuleHook, err error)
func (*ModuleHook) GetConfigDescription ¶
func (m *ModuleHook) GetConfigDescription() string
func (*ModuleHook) Order ¶
func (m *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) Run ¶
func (h *ModuleHook) Run(bindingType BindingType, context []BindingContext, logLabels map[string]string) error
func (*ModuleHook) WithConfig ¶
func (m *ModuleHook) WithConfig(configOutput []byte) (err error)
func (*ModuleHook) WithModule ¶
func (m *ModuleHook) WithModule(module *Module)
type ModuleHookConfig ¶
type ModuleHookConfig struct { sh_op_hook.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 (*ModuleHookConfig) Bindings ¶
func (c *ModuleHookConfig) Bindings() []BindingType
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 interface { Init() error Start() Ch() chan Event WithContext(ctx context.Context) WithDirectories(modulesDir string, globalHooksDir string, tempDir string) ModuleManager WithKubeEventManager(kube_events_manager.KubeEventsManager) WithScheduleManager(schedule_manager.ScheduleManager) WithKubeConfigManager(kubeConfigManager kube_config_manager.KubeConfigManager) ModuleManager WithHelmResourcesManager(manager helm_resources_manager.HelmResourcesManager) WithMetricStorage(storage *metrics_storage.MetricStorage) GetModule(name string) *Module GetModuleNamesInOrder() []string GetModuleHookNames(moduleName string) []string GetGlobalHook(name string) *GlobalHook GetModuleHook(name string) *ModuleHook GetGlobalHooksInOrder(bindingType BindingType) []string GetModuleHooksInOrder(moduleName string, bindingType BindingType) []string GlobalConfigValues() utils.Values GlobalValues() (utils.Values, error) GlobalValuesPatches() []utils.ValuesPatch DiscoverModulesState(logLabels map[string]string) (*ModulesState, error) DeleteModule(moduleName string, logLabels map[string]string) error RunModule(moduleName string, onStartup bool, logLabels map[string]string, afterStartupCb func() error) (bool, error) RunGlobalHook(hookName string, binding BindingType, bindingContext []BindingContext, logLabels map[string]string) (beforeChecksum string, afterChecksum string, err error) RunModuleHook(hookName string, binding BindingType, bindingContext []BindingContext, logLabels map[string]string) error Retry() RegisterModuleHooks(module *Module, logLabels map[string]string) error HandleKubeEvent(kubeEvent KubeEvent, createGlobalTaskFn func(*GlobalHook, controller.BindingExecutionInfo), createModuleTaskFn func(*Module, *ModuleHook, controller.BindingExecutionInfo)) HandleGlobalEnableKubernetesBindings(hookName string, createTaskFn func(*GlobalHook, controller.BindingExecutionInfo)) error HandleModuleEnableKubernetesBindings(hookName string, createTaskFn func(*ModuleHook, controller.BindingExecutionInfo)) error StartModuleHooks(moduleName string) //EnableScheduleBindings() DisableModuleHooks(moduleName string) HandleScheduleEvent(crontab string, createGlobalTaskFn func(*GlobalHook, controller.BindingExecutionInfo), createModuleTaskFn func(*Module, *ModuleHook, controller.BindingExecutionInfo)) error }
type ModulesState ¶
type ModulesState struct { // modules that should be run EnabledModules []string // modules that should be deleted ModulesToDisable []string // modules that should be purged ReleasedUnknownModules []string // modules that was disabled and now are enabled NewlyEnabledModules []string }
ModulesState is a result of Discovery process, that determines which modules should be enabled, disabled or purged.