From 46f8148f5b90bf6e77a857e207f449e1e21173c0 Mon Sep 17 00:00:00 2001 From: Eugene Fedorenko Date: Thu, 21 Nov 2024 09:56:45 -0800 Subject: [PATCH] filter deploymenttargets by environment --- controllers/schedulingpolicy_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/schedulingpolicy_controller.go b/controllers/schedulingpolicy_controller.go index 7c5c9a5..4736bd4 100644 --- a/controllers/schedulingpolicy_controller.go +++ b/controllers/schedulingpolicy_controller.go @@ -100,9 +100,9 @@ func (r *SchedulingPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Req return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list ClusterTypes") } - // fetch the list if deployment targets in the namespace + // fetch the list if deployment targets in the namespace with environment field equal to the namespace name deploymentTargets := &schedulerv1alpha1.DeploymentTargetList{} - err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace)) + err = r.List(ctx, deploymentTargets, client.InNamespace(req.Namespace), client.MatchingFields{"environment": req.Namespace}) if err != nil { return r.manageFailure(ctx, reqLogger, schedulingPolicy, err, "Failed to list DeploymentTargets") }