-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.go
49 lines (38 loc) · 1.32 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
41
42
43
44
45
46
47
48
49
package httppollersource
import (
"context"
"github.com/kelseyhightower/envconfig"
"knative.dev/eventing/pkg/reconciler/source"
"knative.dev/pkg/configmap"
"knative.dev/pkg/controller"
"github.com/zeiss/typhoon/pkg/apis/sources/v1alpha1"
informerv1alpha1 "github.com/zeiss/typhoon/pkg/client/generated/injection/informers/sources/v1alpha1/httppollersource"
reconcilerv1alpha1 "github.com/zeiss/typhoon/pkg/client/generated/injection/reconciler/sources/v1alpha1/httppollersource"
common "github.com/zeiss/typhoon/pkg/reconciler"
)
// NewController creates a Reconciler for the event source and returns the result of NewImpl.
func NewController(
ctx context.Context,
cmw configmap.Watcher,
) *controller.Impl {
typ := (*v1alpha1.HTTPPollerSource)(nil)
app := common.ComponentName(typ)
adapterCfg := &adapterConfig{
configs: source.WatchConfigurations(ctx, app, cmw),
}
envconfig.MustProcess(app, adapterCfg)
informer := informerv1alpha1.Get(ctx)
r := &Reconciler{
adapterCfg: adapterCfg,
}
impl := reconcilerv1alpha1.NewImpl(ctx, r)
r.base = common.NewGenericDeploymentReconciler[*v1alpha1.HTTPPollerSource](
ctx,
typ.GetGroupVersionKind(),
impl.Tracker,
impl.EnqueueControllerOf,
informer.Lister().HTTPPollerSources,
)
informer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue))
return impl
}