This PR resolves https://github.com/grafana/grafana-app-sdk/issues/385 by introducing a new way to write and run apps focused around app logic implementing the interface app.App, and runtime logic (such as a standalone operator) existing as a layer over app.App which translates runtime-specific behaviors into the app.App method calls.
App Logic
App logic is now handled as implementation of the new app.App interface, which describes all possible app behaviors. A default implementation, akin to simple.Operator, exists as simple.App (created with simple.NewApp). A user can also write a custom implementation of app.App if they so wish, and it should be compatible with any runner that consumes an app.App/app.Provider.
app.Provider is an interface for usage by runners, which provides an app.Manifest to the runner to get app capabilities, and then allows for creation of an app.App with configuration sourced from the runner (such as KubeConfig, which may have varying methods by which it is loaded depending on the runner).
Runtime Logic
This PR introduces only one runner, simple.StandaloneOperator, which runs an app as a standalone operator. Combined with simple.App, this gives users the same (and slightly more) functionality that simple.Operator currently does. Planned in a future PR is plugin.App (or a similar name), which will run the app as a plugin and translate gRPC admission and CallResource calls into the app method calls.
Codegen & Documentation
Codegen for grafana-app-sdk component add will be introduced in a future PR to keep this one lighter, alongside documentation and examples for writing an app in this new manner (and existing documentation will be updated to working with apps this way). This PR is focused on introducing the new functionality, and as the "old" (current) way of writing apps is still perfectly valid, documentation will be added and updated in a docs-focused PR.
Other Changes
This PR also contains a drive-by fix for app manifest go codegen, as it currently improperly duplicates the Validation field for mutation when enabled.
What This PR Does / Why We Need It
This PR resolves https://github.com/grafana/grafana-app-sdk/issues/385 by introducing a new way to write and run apps focused around app logic implementing the interface
app.App
, and runtime logic (such as a standalone operator) existing as a layer overapp.App
which translates runtime-specific behaviors into theapp.App
method calls.App Logic
App logic is now handled as implementation of the new
app.App
interface, which describes all possible app behaviors. A default implementation, akin tosimple.Operator
, exists assimple.App
(created withsimple.NewApp
). A user can also write a custom implementation ofapp.App
if they so wish, and it should be compatible with any runner that consumes anapp.App
/app.Provider
.app.Provider
is an interface for usage by runners, which provides anapp.Manifest
to the runner to get app capabilities, and then allows for creation of anapp.App
with configuration sourced from the runner (such as KubeConfig, which may have varying methods by which it is loaded depending on the runner).Runtime Logic
This PR introduces only one runner,
simple.StandaloneOperator
, which runs an app as a standalone operator. Combined withsimple.App
, this gives users the same (and slightly more) functionality thatsimple.Operator
currently does. Planned in a future PR isplugin.App
(or a similar name), which will run the app as a plugin and translate gRPC admission and CallResource calls into the app method calls.Codegen & Documentation
Codegen for
grafana-app-sdk component add
will be introduced in a future PR to keep this one lighter, alongside documentation and examples for writing an app in this new manner (and existing documentation will be updated to working with apps this way). This PR is focused on introducing the new functionality, and as the "old" (current) way of writing apps is still perfectly valid, documentation will be added and updated in a docs-focused PR.Other Changes
This PR also contains a drive-by fix for app manifest go codegen, as it currently improperly duplicates the
Validation
field for mutation when enabled.