controller-runtime icon indicating copy to clipboard operation
controller-runtime copied to clipboard

Add support for fieldSelector to fakeClient

Open grzesuav opened this issue 3 years ago • 4 comments

Currently it seems only labelSelector is supported - https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/fake/client.go#L423

grzesuav avatar Jul 01 '22 13:07 grzesuav

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Sep 29 '22 14:09 k8s-triage-robot

If there's consensus from the project maintainers me and @pleic would like to open a PR to add this, since we have code that needs it. If there's not immediate consensus (e.g. because a real API server should be used with envtest rather than the fake client) we'll elaborate more on our use case and try to make a case for this.

Our rough idea to implement this was to:

  1. add a WithIndex(gvk schema.GroupVersionKind, IndexName, IndexFunc) function to the fake client builder.
  2. add a field of type map[schema.GroupVersionResource]map[string]IndexFunc that stores all the Indexes that have been registered with the fake client on a per GroupVersionResource basis.
  3. when a List requests specifies a field selector, we intercept the normal list results and filter it by lazily computing all the relevant indexes and dropping the list items that don't satisfy the selector.

cc @alvaroaleman @vincepri since you reviewed the previous attempt at this: https://github.com/kubernetes-sigs/controller-runtime/pull/800

matteoolivi avatar Oct 11 '22 23:10 matteoolivi

sounds good to me

alvaroaleman avatar Oct 12 '22 22:10 alvaroaleman

/remove-lifecycle stale

FillZpp avatar Oct 13 '22 02:10 FillZpp

PR opened: https://github.com/kubernetes-sigs/controller-runtime/pull/2025

matteoolivi avatar Oct 18 '22 15:10 matteoolivi

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 16 '23 16:01 k8s-triage-robot

Fixed in https://github.com/kubernetes-sigs/controller-runtime/pull/2025

alvaroaleman avatar Jan 16 '23 16:01 alvaroaleman