From 80ad9965e5079104dfa9994c99c3c0290831df61 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Wed, 12 Nov 2025 10:32:51 -0500 Subject: [PATCH] [cozystack-api] Fix List kinds Signed-off-by: Andrei Kvapil --- hack/e2e-test-openapi.bats | 23 +++++++++++++++++++++++ pkg/registry/apps/application/rest.go | 10 ++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hack/e2e-test-openapi.bats b/hack/e2e-test-openapi.bats index aaddbe84..32128f07 100644 --- a/hack/e2e-test-openapi.bats +++ b/hack/e2e-test-openapi.bats @@ -19,3 +19,26 @@ curl -sS --fail 'http://localhost:21234/openapi/v2?timeout=32s' -H 'Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf' > /dev/null ) } + +@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" + exit 1 + fi +} diff --git a/pkg/registry/apps/application/rest.go b/pkg/registry/apps/application/rest.go index 37a5d9a5..6eaf35ba 100644 --- a/pkg/registry/apps/application/rest.go +++ b/pkg/registry/apps/application/rest.go @@ -1196,12 +1196,18 @@ func (r *REST) Destroy() { // New creates a new instance of Application func (r *REST) New() runtime.Object { - return &appsv1alpha1.Application{} + app := &unstructured.UnstructuredList{} + app.SetAPIVersion("apps.cozystack.io/v1alpha1") + app.SetKind(r.kindName) + return app } // NewList returns an empty list of Application objects func (r *REST) NewList() runtime.Object { - return &appsv1alpha1.ApplicationList{} + appList := &unstructured.UnstructuredList{} + appList.SetAPIVersion("apps.cozystack.io/v1alpha1") + appList.SetKind(r.kindName + "List") + return appList } // Kind returns the resource kind used for API discovery