-
Notifications
You must be signed in to change notification settings - Fork 62
/
run.go
46 lines (39 loc) · 1.23 KB
/
run.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
41
42
43
44
45
46
package controllers
import (
"context"
"github.com/cnoe-io/idpbuilder/pkg/controllers/gitrepository"
"github.com/cnoe-io/idpbuilder/pkg/controllers/localbuild"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
func RunControllers(ctx context.Context, mgr manager.Manager, exitCh chan error, ctxCancel context.CancelFunc) error {
log := log.FromContext(ctx)
// Run Localbuild controller
if err := (&localbuild.LocalbuildReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
CancelFunc: ctxCancel,
}).SetupWithManager(mgr); err != nil {
log.Error(err, "unable to create localbuild controller")
return err
}
err := (&gitrepository.RepositoryReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("gitrepository-controller"),
GiteaClientFunc: gitrepository.NewGiteaClient,
}).SetupWithManager(mgr, nil)
if err != nil {
log.Error(err, "unable to create repo controller")
}
// Start our manager in another goroutine
log.Info("starting manager")
go func() {
if err := mgr.Start(ctx); err != nil {
log.Error(err, "problem running manager")
exitCh <- err
}
exitCh <- nil
}()
return nil
}