From ebe9a1b0a5c6a2aba1ff8ec03c4532354af5126c Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Tue, 10 Dec 2024 12:40:29 +0100 Subject: [PATCH] Fix Terraform compatibility (#524) Signed-off-by: Andrei Kvapil ## Summary by CodeRabbit - **New Features** - Enhanced dynamic registration capabilities for internal API versions of `Application` and `ApplicationList`. - Added configuration management for server options, allowing users to specify a resource configuration path via command line. - **Bug Fixes** - Improved error handling for loading resource configurations. - **Documentation** - Updated OpenAPI specification handling by removing certain definitions post-processing. Signed-off-by: Andrei Kvapil --- pkg/apis/apps/v1alpha1/register.go | 4 ++++ pkg/cmd/server/start.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pkg/apis/apps/v1alpha1/register.go b/pkg/apis/apps/v1alpha1/register.go index cedebac79..2849b0789 100644 --- a/pkg/apis/apps/v1alpha1/register.go +++ b/pkg/apis/apps/v1alpha1/register.go @@ -72,6 +72,10 @@ func RegisterDynamicTypes(scheme *runtime.Scheme, cfg *config.ResourceConfig) er scheme.AddKnownTypeWithName(gvk, &Application{}) scheme.AddKnownTypeWithName(gvk.GroupVersion().WithKind(kind+"List"), &ApplicationList{}) + gvkInternal := schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}.WithKind(kind) + scheme.AddKnownTypeWithName(gvkInternal, &Application{}) + scheme.AddKnownTypeWithName(gvkInternal.GroupVersion().WithKind(kind+"List"), &ApplicationList{}) + klog.V(1).Infof("Registered kind: %s\n", kind) RegisteredGVKs = append(RegisteredGVKs, gvk) } diff --git a/pkg/cmd/server/start.go b/pkg/cmd/server/start.go index 6593f17ad..cfec44de6 100644 --- a/pkg/cmd/server/start.go +++ b/pkg/cmd/server/start.go @@ -256,6 +256,9 @@ func (o *AppsServerOptions) Config() (*apiserver.Config, error) { klog.V(6).Infof("PostProcessSpec: Added OpenAPI definition for %s\n", listResourceName) } + delete(defs, "com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.Application") + delete(defs, "com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.ApplicationList") + swagger.Definitions = defs return swagger, nil }