package controller

import (
	ctrl "sigs.k8s.io/controller-runtime"
)

// SetupAll registers both controllers with the manager.
func SetupAll(mgr ctrl.Manager, destNamespace, destConfigMap string) error {
	base := func(recorder string) baseReconciler {
		return baseReconciler{
			Client:        mgr.GetClient(),
			Scheme:        mgr.GetScheme(),
			Recorder:      mgr.GetEventRecorderFor(recorder),
			DestNamespace: destNamespace,
			DestConfigMap: destConfigMap,
		}
	}
	if err := (&PVCReconciler{baseReconciler: base("autobackup-pvc")}).SetupWithManager(mgr); err != nil {
		return err
	}
	if err := (&ClusterReconciler{baseReconciler: base("autobackup-cluster")}).SetupWithManager(mgr); err != nil {
		return err
	}
	return nil
}
