Documentation ¶
Index ¶
- Variables
- func Init()
- type BindingContext
- type BindingType
- type ChangeType
- type CommonHook
- type Event
- type EventType
- type GlobalHook
- type GlobalHookConfig
- type Hook
- type HookConfig
- type HookExecutor
- type MainModuleManager
- func (mm *MainModuleManager) DeleteModule(moduleName string) error
- func (mm *MainModuleManager) DiscoverModulesState() (state *ModulesState, err error)
- func (mm *MainModuleManager) GetGlobalHook(name string) (*GlobalHook, error)
- func (mm *MainModuleManager) GetGlobalHooksInOrder(bindingType BindingType) []string
- func (mm *MainModuleManager) GetModule(name string) (*Module, error)
- func (mm *MainModuleManager) GetModuleHook(name string) (*ModuleHook, error)
- func (mm *MainModuleManager) GetModuleHooksInOrder(moduleName string, bindingType BindingType) ([]string, error)
- func (mm *MainModuleManager) GetModuleNamesInOrder() []string
- func (mm *MainModuleManager) Init() error
- func (mm *MainModuleManager) Retry()
- func (mm *MainModuleManager) Run()
- func (mm *MainModuleManager) RunGlobalHook(hookName string, binding BindingType, bindingContext []BindingContext) error
- func (mm *MainModuleManager) RunModule(moduleName string, onStartup bool) error
- func (mm *MainModuleManager) RunModuleHook(hookName string, binding BindingType, bindingContext []BindingContext) error
- func (mm *MainModuleManager) WithDirectories(modulesDir string, globalHooksDir string, tempDir string) ModuleManager
- func (mm *MainModuleManager) WithKubeConfigManager(kubeConfigManager kube_config_manager.KubeConfigManager) ModuleManager
- type Module
- type ModuleChange
- type ModuleHook
- type ModuleHookConfig
- type ModuleManager
- type ModulesState
Constants ¶
This section is empty.
Variables ¶
var ContextBindingType = map[BindingType]string{ BeforeHelm: "beforeHelm", AfterHelm: "afterHelm", AfterDeleteHelm: "afterDeleteHelm", BeforeAll: "beforeAll", AfterAll: "afterAll", Schedule: "schedule", OnStartup: "onStartup", KubeEvents: "onKubernetesEvent", }
ContextBindingType is a reverse index for BindingType constants to use in BINDING_CONTEXT_PATH file.
var (
EventCh chan Event
)
Functions ¶
Types ¶
type BindingContext ¶
type BindingContext struct { Binding string `json:"binding"` ResourceEvent string `json:"resourceEvent,omitempty"` ResourceNamespace string `json:"resourceNamespace,omitempty"` ResourceKind string `json:"resourceKind,omitempty"` ResourceName string `json:"resourceName,omitempty"` }
BindingContext is a json with additional info for schedule and onKubeEvent hooks
type BindingType ¶
type BindingType string
BindingType is types of events that can trigger hooks.
const ( BeforeHelm BindingType = "BEFORE_HELM" AfterHelm BindingType = "AFTER_HELM" AfterDeleteHelm BindingType = "AFTER_DELETE_HELM" BeforeAll BindingType = "BEFORE_ALL" AfterAll BindingType = "AFTER_ALL" Schedule BindingType = "SCHEDULE" OnStartup BindingType = "ON_STARTUP" KubeEvents BindingType = "KUBE_EVENTS" )
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 ¶
type CommonHook struct { // The unique name like 'global-hooks/startup_hook' or '002-module/hooks/cleanup'. Name string // The absolute path of the executable file. Path string Bindings []BindingType OrderByBinding map[BindingType]float64 // contains filtered or unexported fields }
func NewHook ¶
func NewHook(name, path string, mm *MainModuleManager) *CommonHook
func (*CommonHook) GetName ¶
func (h *CommonHook) GetName() string
func (*CommonHook) GetPath ¶
func (h *CommonHook) GetPath() string
func (*CommonHook) SafeName ¶
func (h *CommonHook) SafeName() string
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, config *GlobalHookConfig, mm *MainModuleManager) *GlobalHook
func (*GlobalHook) PrepareTmpFilesForHookRun ¶
func (h *GlobalHook) PrepareTmpFilesForHookRun(context []BindingContext) (tmpFiles map[string]string, err error)
PrepareTmpFilesForHookRun creates temporary files for hook and returns environment variables with paths
type GlobalHookConfig ¶
type GlobalHookConfig struct { HookConfig BeforeAll interface{} `json:"beforeAll"` AfterAll interface{} `json:"afterAll"` }
type HookConfig ¶
type HookConfig struct { OnStartup interface{} `json:"onStartup"` Schedule []schedule_manager.ScheduleConfig `json:"schedule"` OnKubernetesEvent []kube_events_manager.OnKubernetesEventConfig `json:"onKubernetesEvent"` }
type HookExecutor ¶
type HookExecutor struct { Hook Hook Context []BindingContext ConfigValuesPath string ValuesPath string ContextPath string ConfigValuesPatchPath string ValuesPatchPath string }
func NewHookExecutor ¶
func NewHookExecutor(h Hook, context []BindingContext) *HookExecutor
func (*HookExecutor) Run ¶
func (e *HookExecutor) Run() (patches map[utils.ValuesPatchType]*utils.ValuesPatch, err error)
type MainModuleManager ¶
type MainModuleManager struct { // Directories ModulesDir string GlobalHooksDir string TempDir string // contains filtered or unexported fields }
func NewMainModuleManager ¶
func NewMainModuleManager() *MainModuleManager
NewMainModuleManager returns new MainModuleManager
func (*MainModuleManager) DeleteModule ¶
func (mm *MainModuleManager) DeleteModule(moduleName string) error
TODO: moduleManager.Module(modName).Delete()
func (*MainModuleManager) DiscoverModulesState ¶
func (mm *MainModuleManager) DiscoverModulesState() (state *ModulesState, err error)
DiscoverModulesState handles DiscoverModulesState event: it calculates new arrays of enabled modules, modules that should be disabled and modules that should be purged.
This method requires that mm.enabledModulesByConfig and mm.kubeModulesConfigValues are updated.
func (*MainModuleManager) GetGlobalHook ¶
func (mm *MainModuleManager) GetGlobalHook(name string) (*GlobalHook, error)
func (*MainModuleManager) GetGlobalHooksInOrder ¶
func (mm *MainModuleManager) GetGlobalHooksInOrder(bindingType BindingType) []string
func (*MainModuleManager) GetModule ¶
func (mm *MainModuleManager) GetModule(name string) (*Module, error)
TODO replace with Module and ModuleShouldExists
func (*MainModuleManager) GetModuleHook ¶
func (mm *MainModuleManager) GetModuleHook(name string) (*ModuleHook, error)
func (*MainModuleManager) GetModuleHooksInOrder ¶
func (mm *MainModuleManager) GetModuleHooksInOrder(moduleName string, bindingType BindingType) ([]string, error)
func (*MainModuleManager) GetModuleNamesInOrder ¶
func (mm *MainModuleManager) GetModuleNamesInOrder() []string
func (*MainModuleManager) Init ¶
func (mm *MainModuleManager) Init() error
Init — initialize module manager
func (*MainModuleManager) Retry ¶
func (mm *MainModuleManager) Retry()
func (*MainModuleManager) RunGlobalHook ¶
func (mm *MainModuleManager) RunGlobalHook(hookName string, binding BindingType, bindingContext []BindingContext) error
func (*MainModuleManager) RunModule ¶
func (mm *MainModuleManager) RunModule(moduleName string, onStartup bool) error
RunModule runs beforeHelm hook, helm upgrade --install and afterHelm or afterDeleteHelm hook
func (*MainModuleManager) RunModuleHook ¶
func (mm *MainModuleManager) RunModuleHook(hookName string, binding BindingType, bindingContext []BindingContext) error
func (*MainModuleManager) WithDirectories ¶
func (mm *MainModuleManager) WithDirectories(modulesDir string, globalHooksDir string, tempDir string) ModuleManager
func (*MainModuleManager) WithKubeConfigManager ¶
func (mm *MainModuleManager) WithKubeConfigManager(kubeConfigManager kube_config_manager.KubeConfigManager) ModuleManager
type Module ¶
type Module struct { Name string DirectoryName string Path string StaticConfig *utils.ModuleConfig // contains filtered or unexported fields }
func NewModule ¶
func NewModule(mm *MainModuleManager) *Module
func (*Module) Delete ¶
Delete removes helm release if it exists and runs afterDeleteHelm hooks. It is a handler for MODULE_DELETE task.
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, config *ModuleHookConfig, mm *MainModuleManager) *ModuleHook
func (*ModuleHook) PrepareTmpFilesForHookRun ¶
func (h *ModuleHook) PrepareTmpFilesForHookRun(context []BindingContext) (tmpFiles map[string]string, err error)
PrepareTmpFilesForHookRun creates temporary files for hook and returns environment variables with paths
type ModuleHookConfig ¶
type ModuleHookConfig struct { HookConfig BeforeHelm interface{} `json:"beforeHelm"` AfterHelm interface{} `json:"afterHelm"` AfterDeleteHelm interface{} `json:"afterDeleteHelm"` }
type ModuleManager ¶
type ModuleManager interface { Init() error Run() DiscoverModulesState() (*ModulesState, error) GetModule(name string) (*Module, error) GetModuleNamesInOrder() []string GetGlobalHook(name string) (*GlobalHook, error) GetModuleHook(name string) (*ModuleHook, error) GetGlobalHooksInOrder(bindingType BindingType) []string GetModuleHooksInOrder(moduleName string, bindingType BindingType) ([]string, error) DeleteModule(moduleName string) error RunModule(moduleName string, onStartup bool) error RunGlobalHook(hookName string, binding BindingType, bindingContext []BindingContext) error RunModuleHook(hookName string, binding BindingType, bindingContext []BindingContext) error Retry() WithDirectories(modulesDir string, globalHooksDir string, tempDir string) ModuleManager WithKubeConfigManager(kubeConfigManager kube_config_manager.KubeConfigManager) ModuleManager }
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 }
ModulesState is a result of Discovery process, that determines which modules should be enabled, disabled or purged.