Documentation
¶
Index ¶
- Variables
- func Init()
- type BindingContext
- type BindingType
- type ChangeType
- type Event
- type EventType
- type GlobalHook
- type GlobalHookConfig
- type Hook
- type HookConfig
- 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) NewModule() *Module
- 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) WithHelmClient(helm helm.HelmClient) 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 ( // Deprecated: Module becomes enabled is handled by module discovery. Enabled ChangeType = "MODULE_ENABLED" // Deprecated: Module become disabled is handled by module discovery. Disabled ChangeType = "MODULE_DISABLED" // Module values are changed Changed ChangeType = "MODULE_CHANGED" // Deprecated: Module files are no longer available is handled by module discovery. Purged ChangeType = "MODULE_PURGED" )
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 { *Hook Config *GlobalHookConfig }
type GlobalHookConfig ¶
type GlobalHookConfig struct { HookConfig BeforeAll interface{} `json:"beforeAll"` AfterAll interface{} `json:"afterAll"` }
type Hook ¶
type Hook struct { Name string // The unique name like 'global-hooks/startup_hook or 002-module/hooks/cleanup'. Path string // The absolute path to the executable file. Bindings []BindingType OrderByBinding map[BindingType]float64 // contains filtered or unexported fields }
type HookConfig ¶
type HookConfig struct { OnStartup interface{} `json:"onStartup"` Schedule []schedule_manager.ScheduleConfig `json:"schedule"` OnKubernetesEvent []kube_events_manager.OnKubernetesEventConfig `json:"onKubernetesEvent"` }
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. This method needs updated mm.enabledModulesByConfig and mm.kubeModulesConfigValues
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) NewModule ¶
func (mm *MainModuleManager) NewModule() *Module
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
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) WithHelmClient ¶
func (mm *MainModuleManager) WithHelmClient(helm helm.HelmClient) 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 }
type ModuleChange ¶
type ModuleChange struct { Name string ChangeType ChangeType }
ModuleChange contains module name and type of module changes.
type ModuleHook ¶
type ModuleHook struct { *Hook Module *Module Config *ModuleHookConfig }
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 WithHelmClient(helm helm.HelmClient) ModuleManager WithKubeConfigManager(kubeConfigManager kube_config_manager.KubeConfigManager) ModuleManager }
type ModulesState ¶
type ModulesState struct { EnabledModules []string ModulesToDisable []string ReleasedUnknownModules []string }
All modules are in the right order to run/disable/purge