Skip to content

Commit 4959d45

Browse files
committed
use client.MatchingFields{} directly
1 parent 7e6925f commit 4959d45

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

doc/user/client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
159159
opts := []client.ListOption{
160160
client.InNamespace(request.NamespacedName.Namespace),
161161
client.MatchingLabels{"app", request.NamespacedName.Name},
162-
client.MatchingField("status.phase", "Running"),
162+
client.MatchingFields{"status.phase", "Running"},
163163
}
164164
ctx := context.TODO()
165165
err := r.client.List(ctx, podList, opts...)

internal/util/k8sutil/options.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import (
1919
"sigs.k8s.io/controller-runtime/pkg/client"
2020
)
2121

22+
// NOTE: use controller-runtime's version of MatchingFields if the following
23+
// issue is accepted as a feature:
24+
// https://github.com/kubernetes-sigs/controller-runtime/issues/576
25+
2226
// MatchingFields implements the client.ListOption and client.DeleteAllOfOption
2327
// interfaces so fields.Selector can be used directly in client.List and
2428
// client.DeleteAllOf.

test/e2e/_incluster-test-code/memcached_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func verifyLeader(t *testing.T, namespace string, f *framework.Framework, labels
141141
opts := []client.ListOption{
142142
client.InNamespace(namespace),
143143
client.MatchingLabels(labels),
144-
client.MatchingField("status.phase", "Running"),
144+
client.MatchingFields{"status.phase", "Running"},
145145
}
146146
err = f.Client.List(goctx.TODO(), pods, opts...)
147147
if err != nil {
@@ -425,7 +425,7 @@ func getMetrics(t *testing.T, f *framework.Framework, labels map[string]string,
425425
opts := []client.ListOption{
426426
client.InNamespace(ns),
427427
client.MatchingLabels(labels),
428-
client.MatchingField("status.phase", "Running"),
428+
client.MatchingFields{"status.phase", "Running"},
429429
}
430430
err := f.Client.List(goctx.TODO(), pods, opts...)
431431
if err != nil {

0 commit comments

Comments
 (0)