From fc9632df61687ef8bf662e4381384cff4c50ca9f Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 2 Oct 2025 18:25:37 +0300 Subject: [PATCH] starts a stub server --- apps/history/pkg/app/app.go | 53 +++++++++++++++++++++++++++ pkg/registry/apps/history/register.go | 6 +-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 apps/history/pkg/app/app.go diff --git a/apps/history/pkg/app/app.go b/apps/history/pkg/app/app.go new file mode 100644 index 00000000000..619bfa07c10 --- /dev/null +++ b/apps/history/pkg/app/app.go @@ -0,0 +1,53 @@ +package app + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/grafana/grafana-app-sdk/app" + "github.com/grafana/grafana-app-sdk/logging" + "github.com/grafana/grafana-app-sdk/resource" + "github.com/grafana/grafana-app-sdk/simple" + + "github.com/grafana/grafana/apps/history/pkg/apis/history/v0alpha1" +) + +func New(cfg app.Config) (app.App, error) { + simpleConfig := simple.AppConfig{ + Name: "history", + KubeConfig: cfg.KubeConfig, + InformerConfig: simple.AppInformerConfig{ + ErrorHandler: func(ctx context.Context, err error) { + logging.FromContext(ctx).Error("Informer processing error", "error", err) + }, + }, + ManagedKinds: []simple.AppManagedKind{ + { + Kind: v0alpha1.QueryKind(), + }, + }, + } + + a, err := simple.NewApp(simpleConfig) + if err != nil { + return nil, err + } + + err = a.ValidateManifest(cfg.ManifestData) + if err != nil { + return nil, err + } + + return a, nil +} + +func GetKinds() map[schema.GroupVersion][]resource.Kind { + gv := schema.GroupVersion{ + Group: v0alpha1.QueryKind().Group(), + Version: v0alpha1.QueryKind().Version(), + } + return map[schema.GroupVersion][]resource.Kind{ + gv: {v0alpha1.QueryKind()}, + } +} diff --git a/pkg/registry/apps/history/register.go b/pkg/registry/apps/history/register.go index 00ed7da69dc..51451c5e5fc 100644 --- a/pkg/registry/apps/history/register.go +++ b/pkg/registry/apps/history/register.go @@ -6,8 +6,8 @@ import ( "github.com/grafana/grafana-app-sdk/app" appsdkapiserver "github.com/grafana/grafana-app-sdk/k8s/apiserver" "github.com/grafana/grafana-app-sdk/simple" - "github.com/grafana/grafana/apps/correlations/pkg/apis" - correlationsapp "github.com/grafana/grafana/apps/correlations/pkg/app" + "github.com/grafana/grafana/apps/history/pkg/apis" + historyapp "github.com/grafana/grafana/apps/history/pkg/app" "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/setting" ) @@ -28,7 +28,7 @@ func RegisterAppInstaller( installer := &AppInstaller{ cfg: cfg, } - provider := simple.NewAppProvider(apis.LocalManifest(), nil, correlationsapp.New) + provider := simple.NewAppProvider(apis.LocalManifest(), nil, historyapp.New) appConfig := app.Config{ KubeConfig: restclient.Config{}, // this will be overridden by the installer's InitializeApp method