-
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.94 KB
/
actions.go
File metadata and controls
44 lines (38 loc) · 1.94 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.TypeOf(&castai.ActionDeleteNode{}): NewDeleteNodeHandler(log, clientset),
reflect.TypeOf(&castai.ActionDrainNode{}): NewDrainNodeHandler(log, clientset, castNamespace),
reflect.TypeOf(&castai.ActionPatchNode{}): NewPatchNodeHandler(log, clientset),
reflect.TypeOf(&castai.ActionCreateEvent{}): NewCreateEventHandler(log, clientset),
reflect.TypeOf(&castai.ActionChartUpsert{}): NewChartUpsertHandler(log, helmClient),
reflect.TypeOf(&castai.ActionChartUninstall{}): NewChartUninstallHandler(log, helmClient),
reflect.TypeOf(&castai.ActionChartRollback{}): NewChartRollbackHandler(log, helmClient, k8sVersion),
reflect.TypeOf(&castai.ActionDisconnectCluster{}): NewDisconnectClusterHandler(log, clientset),
reflect.TypeOf(&castai.ActionCheckNodeDeleted{}): NewCheckNodeDeletedHandler(log, clientset),
reflect.TypeOf(&castai.ActionCheckNodeStatus{}): NewCheckNodeStatusHandler(log, clientset),
reflect.TypeOf(&castai.ActionEvictPod{}): NewEvictPodHandler(log, clientset),
reflect.TypeOf(&castai.ActionPatch{}): NewPatchHandler(log, dynamicClient),
reflect.TypeOf(&castai.ActionCreate{}): NewCreateHandler(log, dynamicClient),
reflect.TypeOf(&castai.ActionDelete{}): NewDeleteHandler(log, dynamicClient),
}
}
func (h ActionHandlers) Close() error {
return h[reflect.TypeOf(&castai.ActionCreateEvent{})].(*CreateEventHandler).Close()
}