{"modulePath":"github.com/flant/shell-operator","version":"v1.21.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controller\n\n## Variables\n\n```go\nvar NewConversionBindingsController = func() *ConversionBindingsController {\n\treturn \u0026ConversionBindingsController{\n\t\tLinks: make(map[string]map[conversion.Rule]*ConversionBindingToWebhookLink),\n\t}\n}\n```\nNewConversionBindingsController returns an implementation of ConversionBindingsController\n\n```go\nvar NewKubernetesBindingsController = func(logger *log.Logger) *kubernetesBindingsController {\n\treturn \u0026kubernetesBindingsController{\n\t\tBindingMonitorLinks: make(map[string]*KubernetesBindingToMonitorLink),\n\t\tlogger:              logger,\n\t}\n}\n```\nNewKubernetesBindingsController returns an implementation of KubernetesBindingsController\n\n```go\nvar NewScheduleBindingsController = func() *scheduleBindingsController {\n\treturn \u0026scheduleBindingsController{\n\t\tScheduleLinks: make(map[string]*ScheduleBindingToCrontabLink),\n\t}\n}\n```\nNewScheduleBindingsController returns an implementation of ScheduleBindingsController\n\n```go\nvar NewValidatingBindingsController = func() *AdmissionBindingsController {\n\treturn \u0026AdmissionBindingsController{\n\t\tAdmissionLinks: make(map[string]*AdmissionBindingToWebhookLink),\n\t}\n}\n```\nNewValidatingBindingsController returns an implementation of AdmissionBindingsController\n\n## Functions\n\n```go\nfunc ConvertKubeEventToBindingContext(kubeEvent kemtypes.KubeEvent, link *KubernetesBindingToMonitorLink) []bctx.BindingContext\n```\n\n## Types\n\n```go\ntype AdmissionBindingToWebhookLink struct {\n\tBindingType     htypes.BindingType\n\tBindingName     string\n\tConfigurationId string\n\tWebhookId       string\n\t// Useful fields to create a BindingContext\n\tIncludeSnapshots []string\n\tGroup            string\n}\n```\nAdmissionBindingToWebhookLink is a link between a hook and a webhook configuration.\n\n```go\ntype AdmissionBindingsController struct {\n\t// Controller holds validating/mutating bindings from one hook. Hook always belongs to one configurationId.\n\tConfigurationId string\n\t// WebhookId -\u003e link\n\tAdmissionLinks map[string]*AdmissionBindingToWebhookLink\n\n\tValidatingBindings []htypes.ValidatingConfig\n\tMutatingBindings   []htypes.MutatingConfig\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *AdmissionBindingsController) CanHandleEvent(event admission.Event) bool\n```\n\n```go\nfunc (c *AdmissionBindingsController) DisableMutatingBindings()\n```\n\n```go\nfunc (c *AdmissionBindingsController) DisableValidatingBindings()\n```\n\n```go\nfunc (c *AdmissionBindingsController) EnableMutatingBindings()\n```\n\n```go\nfunc (c *AdmissionBindingsController) EnableValidatingBindings()\n```\n\n```go\nfunc (c *AdmissionBindingsController) HandleEvent(_ context.Context, event admission.Event) BindingExecutionInfo\n```\n\n```go\nfunc (c *AdmissionBindingsController) WithMutatingBindings(bindings []htypes.MutatingConfig)\n```\n\n```go\nfunc (c *AdmissionBindingsController) WithValidatingBindings(bindings []htypes.ValidatingConfig)\n```\n\n```go\nfunc (c *AdmissionBindingsController) WithWebhookManager(mgr *admission.WebhookManager)\n```\n\n```go\ntype BindingExecutionInfo struct {\n\tBindingContext      []bctx.BindingContext\n\tIncludeSnapshots    []string\n\tIncludeAllSnapshots bool\n\tAllowFailure        bool\n\tQueueName           string\n\tBinding             string\n\tGroup               string\n\tKubernetesBinding   htypes.OnKubernetesEventConfig\n}\n```\n\n```go\ntype ConversionBindingToWebhookLink struct {\n\tBindingName string\n\t// Useful fields to create a BindingContext\n\tCrdName          string\n\tFromVersion      string\n\tToVersion        string\n\tIncludeSnapshots []string\n\tGroup            string\n}\n```\nConversionBindingToWebhookLink a link between a hook and a kube monitor\n\n```go\ntype ConversionBindingsController struct {\n\t// crdName -\u003e conversionRule id -\u003e link\n\tLinks map[string]map[conversion.Rule]*ConversionBindingToWebhookLink\n\n\tBindings []htypes.ConversionConfig\n\t// contains filtered or unexported fields\n}\n```\nConversionBindingsController holds validating bindings from one hook.\n\n```go\nfunc (c *ConversionBindingsController) CanHandleEvent(crdName string, _ *v1.ConversionRequest, rule conversion.Rule) bool\n```\n\n```go\nfunc (c *ConversionBindingsController) DisableConversionBindings()\n```\n\n```go\nfunc (c *ConversionBindingsController) EnableConversionBindings()\n```\n\n```go\nfunc (c *ConversionBindingsController) HandleEvent(_ context.Context, crdName string, request *v1.ConversionRequest, rule conversion.Rule) BindingExecutionInfo\n```\n\n```go\nfunc (c *ConversionBindingsController) WithBindings(bindings []htypes.ConversionConfig)\n```\n\n```go\nfunc (c *ConversionBindingsController) WithWebhookManager(mgr *conversion.WebhookManager)\n```\n\n```go\ntype HookController struct {\n\tKubernetesController KubernetesBindingsController\n\tScheduleController   ScheduleBindingsController\n\tAdmissionController  *AdmissionBindingsController\n\tConversionController *ConversionBindingsController\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewHookController() *HookController\n```\n\n```go\nfunc (hc *HookController) CanHandleAdmissionEvent(event admission.Event) bool\n```\n\n```go\nfunc (hc *HookController) CanHandleConversionEvent(crdName string, event *v1.ConversionRequest, rule conversion.Rule) bool\n```\n\n```go\nfunc (hc *HookController) CanHandleKubeEvent(kubeEvent kemtypes.KubeEvent) bool\n```\n\n```go\nfunc (hc *HookController) CanHandleScheduleEvent(crontab string) bool\n```\n\n```go\nfunc (hc *HookController) DisableKubernetesBindings()\n```\n\n```go\nfunc (hc *HookController) DisableScheduleBindings()\n```\n\n```go\nfunc (hc *HookController) EnableAdmissionBindings()\n```\n\n```go\nfunc (hc *HookController) EnableConversionBindings()\n```\n\n```go\nfunc (hc *HookController) EnableKubernetesBindings() ([]BindingExecutionInfo, error)\n```\n\n```go\nfunc (hc *HookController) EnableScheduleBindings()\n```\n\n```go\nfunc (hc *HookController) HandleAdmissionEvent(ctx context.Context, event admission.Event, createTasksFn func(BindingExecutionInfo))\n```\n\n```go\nfunc (hc *HookController) HandleConversionEvent(ctx context.Context, crdName string, request *v1.ConversionRequest, rule conversion.Rule, createTasksFn func(BindingExecutionInfo))\n```\n\n```go\nfunc (hc *HookController) HandleEnableKubernetesBindings(_ context.Context, createTasksFn func(BindingExecutionInfo)) error\n```\n\n```go\nfunc (hc *HookController) HandleKubeEvent(ctx context.Context, event kemtypes.KubeEvent, handlerFunc func(BindingExecutionInfo))\n```\n\n```go\nfunc (hc *HookController) HandleKubeEventWithFormTask(ctx context.Context, event kemtypes.KubeEvent, createTasksFn func(BindingExecutionInfo) task.Task) task.Task\n```\n\n```go\nfunc (hc *HookController) HandleScheduleEvent(ctx context.Context, crontab string, handlerFunc func(BindingExecutionInfo))\n```\n\n```go\nfunc (hc *HookController) HandleScheduleEventWithFormTasks(ctx context.Context, crontab string, createTasksFn func(BindingExecutionInfo) task.Task) []task.Task\n```\n\n```go\nfunc (hc *HookController) InitAdmissionBindings(vbindings []htypes.ValidatingConfig, mbindings []htypes.MutatingConfig, webhookMgr *admission.WebhookManager)\n```\n\n```go\nfunc (hc *HookController) InitConversionBindings(bindings []htypes.ConversionConfig, webhookMgr *conversion.WebhookManager)\n```\n\n```go\nfunc (hc *HookController) InitKubernetesBindings(bindings []htypes.OnKubernetesEventConfig, kubeEventMgr kubeeventsmanager.KubeEventsSource, logger *log.Logger)\n```\n\n```go\nfunc (hc *HookController) InitScheduleBindings(bindings []htypes.ScheduleConfig, scheduleMgr schedulemanager.ScheduleRegistry)\n```\n\n```go\nfunc (hc *HookController) KubernetesSnapshots() map[string][]kemtypes.ObjectAndFilterResult\n```\nKubernetesSnapshots returns a 'full snapshot': all snapshots for all registered kubernetes bindings. Note: no caching as in UpdateSnapshots because KubernetesSnapshots used for non-combined binding contexts.\n\n```go\nfunc (hc *HookController) SnapshotsDump() map[string]interface{}\n```\n\n```go\nfunc (hc *HookController) SnapshotsInfo() []string\n```\n\n```go\nfunc (hc *HookController) UnlockKubernetesEvents()\n```\n\n```go\nfunc (hc *HookController) UnlockKubernetesEventsFor(monitorID string)\n```\n\n```go\nfunc (hc *HookController) UpdateMonitor(monitorId string, kind, apiVersion string) error\n```\n\n```go\nfunc (hc *HookController) UpdateSnapshots(context []bctx.BindingContext) []bctx.BindingContext\n```\nUpdateSnapshots ensures fresh consistent snapshots for combined binding contexts.\n\nIt uses caching to retrieve snapshots for a particular binding name only once. This caching is important for Synchronization and self-includes: Combined \"Synchronization\" binging contexts or \"Synchronization\" with self-inclusion may require several calls to Snapshot\\*() methods, but objects may change between these calls.\n\n```go\ntype KubernetesBindingToMonitorLink struct {\n\tMonitorId     string\n\tBindingConfig htypes.OnKubernetesEventConfig\n}\n```\nKubernetesBindingToMonitorLink is a link between a binding config and a Monitor.\n\n```go\ntype KubernetesBindingsController interface {\n\tWithKubernetesBindings([]htypes.OnKubernetesEventConfig)\n\tWithKubeEventsManager(kubeeventsmanager.KubeEventsSource)\n\tEnableKubernetesBindings() ([]BindingExecutionInfo, error)\n\tDisableKubernetesBindings()\n\tUpdateMonitor(monitorId string, kind, apiVersion string) error\n\tUnlockEvents()\n\tUnlockEventsFor(monitorID string)\n\tCanHandleEvent(kubeEvent kemtypes.KubeEvent) bool\n\tHandleEvent(ctx context.Context, kubeEvent kemtypes.KubeEvent) BindingExecutionInfo\n\tBindingNames() []string\n\n\tSnapshotsFrom(bindingNames ...string) map[string][]kemtypes.ObjectAndFilterResult\n\tSnapshotsFor(bindingName string) []kemtypes.ObjectAndFilterResult\n\tSnapshots() map[string][]kemtypes.ObjectAndFilterResult\n\tSnapshotsInfo() []string\n\tSnapshotsDump() map[string]interface{}\n}\n```\nKubernetesBindingsController handles kubernetes bindings for one hook.\n\n```go\ntype ScheduleBindingToCrontabLink struct {\n\tBindingName string\n\tCrontab     string\n\t// Useful fields to create a BindingContext\n\tIncludeSnapshots []string\n\tAllowFailure     bool\n\tQueueName        string\n\tGroup            string\n}\n```\nScheduleBindingToCrontabLink a link between a hook and a kube monitor\n\n```go\ntype ScheduleBindingsController interface {\n\tWithScheduleBindings([]htypes.ScheduleConfig)\n\tWithScheduleManager(schedulemanager.ScheduleRegistry)\n\tEnableScheduleBindings()\n\tDisableScheduleBindings()\n\tCanHandleEvent(crontab string) bool\n\tHandleEvent(ctx context.Context, crontab string) []BindingExecutionInfo\n}\n```\nScheduleBindingsController handles schedule bindings for one hook.\n\n","path":"github.com/flant/shell-operator/pkg/hook/controller","name":"controller","synopsis":"","isRedistributable":true}
