-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathactions.go
More file actions
44 lines (38 loc) · 1.96 KB
/
actions.go
File metadata and controls
44 lines (38 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package actions
import (
"reflect"
"github.com/sirupsen/logrus"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"github.com/castai/cluster-controller/internal/castai"
"github.com/castai/cluster-controller/internal/helm"
)
type ActionHandlers map[reflect.Type]ActionHandler
func NewDefaultActionHandlers(
k8sVersion string,
castNamespace string,
log logrus.FieldLogger,
clientset *kubernetes.Clientset,
dynamicClient dynamic.Interface,
helmClient helm.Client,
) ActionHandlers {
return ActionHandlers{
reflect.TypeFor[*castai.ActionDeleteNode](): NewDeleteNodeHandler(log, clientset),
reflect.TypeFor[*castai.ActionDrainNode](): NewDrainNodeHandler(log, clientset, castNamespace),
reflect.TypeFor[*castai.ActionPatchNode](): NewPatchNodeHandler(log, clientset),
reflect.TypeFor[*castai.ActionCreateEvent](): NewCreateEventHandler(log, clientset),
reflect.TypeFor[*castai.ActionChartUpsert](): NewChartUpsertHandler(log, helmClient),
reflect.TypeFor[*castai.ActionChartUninstall](): NewChartUninstallHandler(log, helmClient),
reflect.TypeFor[*castai.ActionChartRollback](): NewChartRollbackHandler(log, helmClient, k8sVersion),
reflect.TypeFor[*castai.ActionDisconnectCluster](): NewDisconnectClusterHandler(log, clientset),
reflect.TypeFor[*castai.ActionCheckNodeDeleted](): NewCheckNodeDeletedHandler(log, clientset),
reflect.TypeFor[*castai.ActionCheckNodeStatus](): NewCheckNodeStatusHandler(log, clientset),
reflect.TypeFor[*castai.ActionEvictPod](): NewEvictPodHandler(log, clientset),
reflect.TypeFor[*castai.ActionPatch](): NewPatchHandler(log, dynamicClient),
reflect.TypeFor[*castai.ActionCreate](): NewCreateHandler(log, dynamicClient),
reflect.TypeFor[*castai.ActionDelete](): NewDeleteHandler(log, dynamicClient),
}
}
func (h ActionHandlers) Close() error {
return h[reflect.TypeFor[*castai.ActionCreateEvent]()].(*CreateEventHandler).Close()
}