/
controller.go
40 lines (34 loc) · 1.25 KB
/
controller.go
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
// (c) Copyright IBM Corporation 2019, 2020. All Rights Reserved.
// Note to U.S. Government Users Restricted Rights:
// U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule
// Contract with IBM Corp.
//
// Copyright (c) Red Hat, Inc.
// Copyright Contributors to the Open Cluster Management project
package controller
import (
"github.com/stolostron/klusterlet-addon-controller/pkg/controller/addon"
"github.com/stolostron/klusterlet-addon-controller/pkg/controller/globalproxy"
"github.com/stolostron/klusterlet-addon-controller/pkg/controller/managedcluster"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
// AddToManagerFuncs is a list of functions to add all Controllers to the Manager
var AddToManagerFuncs []func(manager.Manager, kubernetes.Interface) error
func init() {
AddToManagerFuncs = append(AddToManagerFuncs,
addon.Add,
managedcluster.Add,
globalproxy.Add,
)
}
// AddToManager adds all Controllers to the Manager
func AddToManager(m manager.Manager, kubeClient kubernetes.Interface, dynamicClient dynamic.Interface) error {
for _, f := range AddToManagerFuncs {
if err := f(m, kubeClient); err != nil {
return err
}
}
return nil
}