diff --git a/staging/src/k8s.io/client-go/testing/fixture.go b/staging/src/k8s.io/client-go/testing/fixture.go index 65c96a47e3d..152a5c1bacb 100644 --- a/staging/src/k8s.io/client-go/testing/fixture.go +++ b/staging/src/k8s.io/client-go/testing/fixture.go @@ -511,6 +511,17 @@ func (t *tracker) Apply(gvr schema.GroupVersionResource, applyConfiguration runt return t.add(gvr, obj, ns, true) } +// IsWatchListSemanticsUnSupported informs the reflector that this client +// doesn't support WatchList semantics. +// +// This is a synthetic method whose sole purpose is to satisfy the optional +// interface check performed by the reflector. +// Returning true signals that WatchList can NOT be used. +// No additional logic is implemented here. +func (t *tracker) IsWatchListSemanticsUnSupported() bool { + return true +} + func (t *tracker) getWatches(gvr schema.GroupVersionResource, ns string) []*watch.RaceFreeFakeWatcher { watches := []*watch.RaceFreeFakeWatcher{} if t.watchers[gvr] != nil { diff --git a/staging/src/k8s.io/client-go/testing/fixture_test.go b/staging/src/k8s.io/client-go/testing/fixture_test.go index 2b6894b0db4..709728b78f5 100644 --- a/staging/src/k8s.io/client-go/testing/fixture_test.go +++ b/staging/src/k8s.io/client-go/testing/fixture_test.go @@ -39,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/managedfields" "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/util/watchlist" "k8s.io/utils/ptr" ) @@ -740,3 +741,14 @@ func TestManagedFielsdObjectTrackerWithUnstructured(t *testing.T) { unstructured.RemoveNestedField(cmActual.Object, "metadata", "managedFields") require.Empty(t, cmp.Diff(cmOriginal, cmActual)) } + +func TestDoesClientSupportWatchListSemantics(t *testing.T) { + scheme := runtime.NewScheme() + codecs := serializer.NewCodecFactory(scheme) + + target := NewObjectTracker(scheme, codecs.UniversalDecoder()) + + if !watchlist.DoesClientNotSupportWatchListSemantics(target) { + t.Fatalf("ObjectTracker should NOT support WatchList semantics") + } +}