Skip to content

Commit 6f7eb57

Browse files
committed
derive controller name from prototype and allow custom name
1 parent a579283 commit 6f7eb57

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/patterns/declarative/reconciler.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,17 @@ func (e *ErrorResult) Error() string {
106106
var defaultApplier = applier.DefaultApplier
107107

108108
func (r *Reconciler) Init(mgr manager.Manager, prototype DeclarativeObject, opts ...ReconcilerOption) error {
109+
controllerName := "addon-controller"
110+
if commonName, err := utils.GetCommonName(prototype); err == nil {
111+
controllerName = commonName + "-controller"
112+
}
113+
114+
return r.InitWithName(mgr, prototype, controllerName, opts...)
115+
}
116+
117+
func (r *Reconciler) InitWithName(mgr manager.Manager, prototype DeclarativeObject, controllerName string, opts ...ReconcilerOption) error {
109118
r.prototype = prototype
110119

111-
// TODO: Can we derive the name from prototype?
112-
controllerName := "addon-controller"
113120
r.recorder = mgr.GetEventRecorderFor(controllerName)
114121

115122
r.client = mgr.GetClient()

0 commit comments

Comments
 (0)