diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go index 27c1c63cfe..c158bb27f8 100644 --- a/pkg/cache/cache_test.go +++ b/pkg/cache/cache_test.go @@ -688,6 +688,14 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca Expect(informerCache.List(context.Background(), listObj, labelOpt, limitOpt)).To(Succeed()) Expect(listObj.Items).Should(HaveLen(1)) }) + + It("should return an error if the continue list options is set", func() { + listObj := &corev1.PodList{} + continueOpt := client.Continue("token") + By("verifying that an error is returned") + err := informerCache.List(context.Background(), listObj, continueOpt) + Expect(err).To(HaveOccurred()) + }) }) Context("with unstructured objects", func() { @@ -1002,6 +1010,13 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca Expect(nodeList.Items).NotTo(BeEmpty()) Expect(len(nodeList.Items)).To(BeEquivalentTo(1)) }) + It("should return an error if the continue list options is set", func() { + podList := &unstructured.Unstructured{} + continueOpt := client.Continue("token") + By("verifying that an error is returned") + err := informerCache.List(context.Background(), podList, continueOpt) + Expect(err).To(HaveOccurred()) + }) }) Context("with metadata-only objects", func() { It("should be able to list objects that haven't been watched previously", func() { diff --git a/pkg/cache/internal/cache_reader.go b/pkg/cache/internal/cache_reader.go index 5d18bed08f..eb941f034e 100644 --- a/pkg/cache/internal/cache_reader.go +++ b/pkg/cache/internal/cache_reader.go @@ -111,6 +111,10 @@ func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...cli listOpts := client.ListOptions{} listOpts.ApplyOptions(opts) + if listOpts.Continue != "" { + return fmt.Errorf("continue list option is not supported by the cache") + } + switch { case listOpts.FieldSelector != nil: // TODO(directxman12): support more complicated field selectors by