From 0b27f634c0de386e57791ec92dfacb21729801aa Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Mon, 1 Dec 2025 19:45:10 +0100 Subject: [PATCH] Revert [api] Fix representation of dynamic list kinds Signed-off-by: Andrei Kvapil --- hack/e2e-test-openapi.bats | 10 ---------- pkg/registry/apps/application/rest.go | 7 +++---- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/hack/e2e-test-openapi.bats b/hack/e2e-test-openapi.bats index 32128f07..d94cb422 100644 --- a/hack/e2e-test-openapi.bats +++ b/hack/e2e-test-openapi.bats @@ -21,21 +21,11 @@ } @test "Test kinds" { - val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/tenants | jq -r '.kind') - if [ "$val" != "TenantList" ]; then - echo "Expected kind to be TenantList, got $val" - exit 1 - fi val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/tenants | jq -r '.items[0].kind') if [ "$val" != "Tenant" ]; then echo "Expected kind to be Tenant, got $val" exit 1 fi - val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/ingresses | jq -r '.kind') - if [ "$val" != "IngressList" ]; then - echo "Expected kind to be IngressList, got $val" - exit 1 - fi val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/ingresses | jq -r '.items[0].kind') if [ "$val" != "Ingress" ]; then echo "Expected kind to be Ingress, got $val" diff --git a/pkg/registry/apps/application/rest.go b/pkg/registry/apps/application/rest.go index 0c2dd3a9..03de7c08 100644 --- a/pkg/registry/apps/application/rest.go +++ b/pkg/registry/apps/application/rest.go @@ -397,9 +397,9 @@ func (r *REST) List(ctx context.Context, options *metainternalversion.ListOption } // Explicitly set apiVersion and kind in unstructured object - appList := r.NewList().(*unstructured.Unstructured) + appList := r.NewList().(*unstructured.UnstructuredList) appList.SetResourceVersion(hrList.GetResourceVersion()) - appList.Object["items"] = items + appList.Items = items klog.V(6).Infof("Successfully listed %d Application resources in namespace %s", len(items), namespace) return appList, nil @@ -1244,9 +1244,8 @@ func (r *REST) New() runtime.Object { // NewList returns an empty list of Application objects func (r *REST) NewList() runtime.Object { - obj := &unstructured.Unstructured{} + obj := &unstructured.UnstructuredList{} obj.SetGroupVersionKind(r.gvk.GroupVersion().WithKind(r.kindName + "List")) - obj.Object["items"] = make([]interface{}, 0) return obj }