Skip to content

Commit

Permalink
Restore controller code
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <[email protected]>
  • Loading branch information
anmazzotti committed Mar 20, 2024
1 parent a7a58da commit 4760ffe
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions controllers/machineselector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

Expand All @@ -62,12 +63,10 @@ type MachineInventorySelectorReconciler struct {
func (r *MachineInventorySelectorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&elementalv1.MachineInventorySelector{}).
// Watches(
// &source.Kind{
// Type: &elementalv1.MachineInventory{},
// },
// handler.EnqueueRequestsFromMapFunc(r.MachineInventoryToSelector),
// ).
Watches(
&elementalv1.MachineInventory{},
handler.EnqueueRequestsFromMapFunc(r.MachineInventoryToSelector),
).
WithEventFilter(filterSelectorUpdateEvents()).
Complete(r)
}
Expand Down Expand Up @@ -611,7 +610,7 @@ func filterSelectorUpdateEvents() predicate.Funcs {

// MachineInventoryToSelector is a handler.ToRequestsFunc to be used to enqueue requests for reconciliation
// for MachineInventoryToSelector that might adopt a MachineInventory.
func (r *MachineInventorySelectorReconciler) MachineInventoryToSelector(o client.Object) []reconcile.Request {
func (r *MachineInventorySelectorReconciler) MachineInventoryToSelector(ctx context.Context, o client.Object) []ctrl.Request {
result := []reconcile.Request{}

mInventory, ok := o.(*elementalv1.MachineInventory)
Expand All @@ -620,7 +619,6 @@ func (r *MachineInventorySelectorReconciler) MachineInventoryToSelector(o client
}

// This won't log unless the global logger is set
ctx := context.Background()
logger := ctrl.LoggerFrom(ctx, "MachineInventory", klog.KObj(mInventory))

// If machine inventory is already owned reconcile its owner
Expand Down

0 comments on commit 4760ffe

Please sign in to comment.