Skip to content

Commit

Permalink
use client.MatchingFields{} directly
Browse files Browse the repository at this point in the history
  • Loading branch information
estroz committed Aug 23, 2019
1 parent 7e6925f commit 4959d45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/user/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
opts := []client.ListOption{
client.InNamespace(request.NamespacedName.Namespace),
client.MatchingLabels{"app", request.NamespacedName.Name},
client.MatchingField("status.phase", "Running"),
client.MatchingFields{"status.phase", "Running"},
}
ctx := context.TODO()
err := r.client.List(ctx, podList, opts...)
Expand Down
4 changes: 4 additions & 0 deletions internal/util/k8sutil/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

// NOTE: use controller-runtime's version of MatchingFields if the following
// issue is accepted as a feature:
// https://github.com/kubernetes-sigs/controller-runtime/issues/576

// MatchingFields implements the client.ListOption and client.DeleteAllOfOption
// interfaces so fields.Selector can be used directly in client.List and
// client.DeleteAllOf.
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/_incluster-test-code/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func verifyLeader(t *testing.T, namespace string, f *framework.Framework, labels
opts := []client.ListOption{
client.InNamespace(namespace),
client.MatchingLabels(labels),
client.MatchingField("status.phase", "Running"),
client.MatchingFields{"status.phase", "Running"},
}
err = f.Client.List(goctx.TODO(), pods, opts...)
if err != nil {
Expand Down Expand Up @@ -425,7 +425,7 @@ func getMetrics(t *testing.T, f *framework.Framework, labels map[string]string,
opts := []client.ListOption{
client.InNamespace(ns),
client.MatchingLabels(labels),
client.MatchingField("status.phase", "Running"),
client.MatchingFields{"status.phase", "Running"},
}
err := f.Client.List(goctx.TODO(), pods, opts...)
if err != nil {
Expand Down

0 comments on commit 4959d45

Please sign in to comment.