pkg/services/apiserver/appinstaller/README.md
An AppInstaller (appsdkapiserver.AppInstaller) is a new concept introduced in v0.40.0 of the Grafana App SDK. It is an interface responsible for installing an app into the Grafana API server. Each app provides an AppInstaller implementation, which is then used by the API server to manage the app.
A new framework for installing and managing apps has been introduced in pkg/services/apiserver/appinstaller. This framework is responsible for:
Grafana's core API server (pkg/services/apiserver/service.go) has been significantly updated to integrate with the new app installer framework. During startup, the API server now performs the following steps:
AppInstaller instances provided by the apps.appinstaller framework to register schemas, admission plugins, and OpenAPI definitions.This ensures that apps are seamlessly integrated into Grafana's API server and that their resources are available through the Grafana API.
The method for registering apps has been updated:
ProvideBuilderRunners in pkg/registry/apps/apps.go is now deprecated.ProvideAppInstallers function, which returns a list of AppInstaller instances.This change streamlines the app registration process and makes it more consistent.
To migrate an existing app to the new SDK, you need to:
appsdkapiserver.AppInstaller interface for your app.ProvideAppInstallers function.The Playlist app has been migrated to the new App SDK. Let's look at how it was done.
Previously, the Playlist app was registered using ProvideBuilderRunners:
// pkg/registry/apps/apps.go (before)
func ProvideBuilderRunners(
// ...
playlistAppProvider *playlist.PlaylistAppProvider,
// ...
) (*Service, error) {
// ...
providers := []app.Provider{playlistAppProvider}
// ...
}
Now, the Playlist app provides an AppInstaller and is registered through ProvideAppInstallers:
// pkg/registry/apps/apps.go (after)
func ProvideAppInstallers(
playlistAppInstaller *playlist.PlaylistAppInstaller,
) []appsdkapiserver.AppInstaller {
return []appsdkapiserver.AppInstaller{playlistAppInstaller}
}
The implementation of the PlaylistAppInstaller can be found in pkg/registry/apps/playlist/register.go. This file is a good reference for how to implement an AppInstaller for your own app.
The pkg/registry/apps/playlist/register.go file does the following:
PlaylistAppInstaller, which embeds appsdkapiserver.AppInstaller.appinstaller.LegacyStorageProvider to bridge with Grafana's existing playlist service.RegisterAppInstaller function initializes the installer, providing the app's manifest, specific configuration, and associating Go types with API kinds.kubectl get style output.