Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *client) Get(ctx context.Context, key ObjectKey, obj runtime.Object) err
// List implements client.Client
func (c *client) List(ctx context.Context, obj runtime.Object, opts ...ListOption) error {
switch obj.(type) {
case *unstructured.Unstructured:
case *unstructured.UnstructuredList:
return c.unstructuredClient.List(ctx, obj, opts...)
case *metav1.PartialObjectMetadataList:
return c.metadataClient.List(ctx, obj, opts...)
Expand Down
30 changes: 30 additions & 0 deletions pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,36 @@ var _ = Describe("Client", func() {
close(done)
}, serverSideTimeoutSeconds)

It("should fetch unstructured collection of objects, even if scheme is empty", func(done Done) {
By("create an initial object")
_, err := clientset.AppsV1().Deployments(ns).Create(dep)
Expect(err).NotTo(HaveOccurred())

cl, err := client.New(cfg, client.Options{Scheme: runtime.NewScheme()})
Expect(err).NotTo(HaveOccurred())

By("listing all objects of that type in the cluster")
deps := &unstructured.UnstructuredList{}
deps.SetGroupVersionKind(schema.GroupVersionKind{
Group: "apps",
Kind: "DeploymentList",
Version: "v1",
})
err = cl.List(context.Background(), deps)
Expect(err).NotTo(HaveOccurred())

Expect(deps.Items).NotTo(BeEmpty())
hasDep := false
for _, item := range deps.Items {
if item.GetName() == dep.Name && item.GetNamespace() == dep.Namespace {
hasDep = true
break
}
}
Expect(hasDep).To(BeTrue())
close(done)
}, serverSideTimeoutSeconds)

It("should return an empty list if there are no matching objects", func(done Done) {
cl, err := client.New(cfg, client.Options{})
Expect(err).NotTo(HaveOccurred())
Expand Down