Skip to content

Commit

Permalink
Use MatchingFields as And logic
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Jan 7, 2025
1 parent d047045 commit 301eb2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions internal/controllers/topology/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ func (r *Reconciler) clusterClassToCluster(ctx context.Context, o client.Object)
if err := r.Client.List(
ctx,
clusterList,
client.MatchingFieldsSelector{Selector: fields.AndSelectors(
fields.OneTermEqualSelector(index.ClusterClassNameField, clusterClass.Name),
fields.OneTermEqualSelector(index.ClusterClassNamespaceField, clusterClass.Namespace),
)},
client.MatchingFields{
index.ClusterClassNameField: clusterClass.Name,
index.ClusterClassNamespaceField: clusterClass.Namespace,
},
); err != nil {
return nil
}
Expand Down
9 changes: 4 additions & 5 deletions internal/webhooks/clusterclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
Expand Down Expand Up @@ -380,10 +379,10 @@ func (webhook *ClusterClass) classNamesFromMPWorkerClass(w clusterv1.WorkersClas
func (webhook *ClusterClass) getClustersUsingClusterClass(ctx context.Context, clusterClass *clusterv1.ClusterClass) ([]clusterv1.Cluster, error) {
clusters := &clusterv1.ClusterList{}
err := webhook.Client.List(ctx, clusters,
client.MatchingFieldsSelector{Selector: fields.AndSelectors(
fields.OneTermEqualSelector(index.ClusterClassNameField, clusterClass.Name),
fields.OneTermEqualSelector(index.ClusterClassNamespaceField, clusterClass.Namespace),
)},
client.MatchingFields{
index.ClusterClassNameField: clusterClass.Name,
index.ClusterClassNamespaceField: clusterClass.Namespace,
},
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 301eb2d

Please sign in to comment.