Wire dashvalidator app with grafana
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/annotation"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/correlations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/dashvalidator"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/example"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/investigations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/logsdrilldown"
|
||||
@@ -47,12 +48,14 @@ func ProvideAppInstallers(
|
||||
advisorAppInstaller *advisor.AdvisorAppInstaller,
|
||||
alertingHistorianAppInstaller *historian.AlertingHistorianAppInstaller,
|
||||
quotasAppInstaller *quotas.QuotasAppInstaller,
|
||||
dashvalidatorAppInstaller *dashvalidator.DashValidatorAppInstaller,
|
||||
) []appsdkapiserver.AppInstaller {
|
||||
featureClient := openfeature.NewDefaultClient()
|
||||
installers := []appsdkapiserver.AppInstaller{
|
||||
playlistAppInstaller,
|
||||
pluginsApplInstaller,
|
||||
exampleAppInstaller,
|
||||
dashvalidatorAppInstaller,
|
||||
}
|
||||
if featureClient.Boolean(context.Background(), featuremgmt.FlagKubernetesUnifiedStorageQuotas, false, openfeature.TransactionContext(context.Background())) {
|
||||
installers = append(installers, quotasAppInstaller)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package dashvalidator
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
appsdkapiserver "github.com/grafana/grafana-app-sdk/k8s/apiserver"
|
||||
"github.com/grafana/grafana-app-sdk/simple"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
|
||||
validatorapis "github.com/grafana/grafana/apps/dashvalidator/pkg/apis/manifestdata"
|
||||
validatorapp "github.com/grafana/grafana/apps/dashvalidator/pkg/app"
|
||||
roleauthorizer "github.com/grafana/grafana/pkg/services/apiserver/auth/authorizer"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||
)
|
||||
|
||||
var _ appsdkapiserver.AppInstaller = (*DashValidatorAppInstaller)(nil)
|
||||
|
||||
type DashValidatorAppInstaller struct {
|
||||
appsdkapiserver.AppInstaller
|
||||
}
|
||||
|
||||
// RegisterAppInstaller is called by Wire to create the app installer
|
||||
func RegisterAppInstaller(
|
||||
datasourceSvc datasources.DataSourceService,
|
||||
pluginCtx *plugincontext.Provider,
|
||||
) (*DashValidatorAppInstaller, error) {
|
||||
// Create specific config for the app
|
||||
specificConfig := &validatorapp.DashValidatorConfig{
|
||||
DatasourceSvc: datasourceSvc,
|
||||
PluginCtx: pluginCtx,
|
||||
}
|
||||
|
||||
// Create the app provider
|
||||
provider := simple.NewAppProvider(
|
||||
validatorapis.LocalManifest(),
|
||||
specificConfig,
|
||||
validatorapp.New,
|
||||
)
|
||||
|
||||
// Create app config
|
||||
appConfig := app.Config{
|
||||
KubeConfig: restclient.Config{}, // Will be overridden by installer
|
||||
ManifestData: *validatorapis.LocalManifest().ManifestData,
|
||||
SpecificConfig: specificConfig,
|
||||
}
|
||||
|
||||
// Create the default installer
|
||||
defaultInstaller, err := appsdkapiserver.NewDefaultAppInstaller(
|
||||
provider,
|
||||
appConfig,
|
||||
validatorapis.NewGoTypeAssociator(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DashValidatorAppInstaller{
|
||||
AppInstaller: defaultInstaller,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetAuthorizer provides the authorization for the app
|
||||
func (a *DashValidatorAppInstaller) GetAuthorizer() authorizer.Authorizer {
|
||||
//nolint:staticcheck
|
||||
return roleauthorizer.NewRoleAuthorizer()
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/annotation"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/correlations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/dashvalidator"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/example"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/investigations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/logsdrilldown"
|
||||
@@ -32,4 +33,5 @@ var WireSet = wire.NewSet(
|
||||
annotation.RegisterAppInstaller,
|
||||
quotas.RegisterAppInstaller,
|
||||
example.RegisterAppInstaller,
|
||||
dashvalidator.RegisterAppInstaller,
|
||||
)
|
||||
|
||||
Generated
+11
-2
@@ -85,6 +85,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/registry/apps/alerting/rules"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/annotation"
|
||||
correlations2 "github.com/grafana/grafana/pkg/registry/apps/correlations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/dashvalidator"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/example"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/investigations"
|
||||
"github.com/grafana/grafana/pkg/registry/apps/logsdrilldown"
|
||||
@@ -831,7 +832,11 @@ func Initialize(ctx context.Context, cfg *setting.Cfg, opts Options, apiOpts api
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, appInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller, alertingNotificationsAppInstaller, logsDrilldownAppInstaller, annotationAppInstaller, exampleAppInstaller, advisorAppInstaller, alertingHistorianAppInstaller, quotasAppInstaller)
|
||||
dashValidatorAppInstaller, err := dashvalidator.RegisterAppInstaller(service15, plugincontextProvider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, appInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller, alertingNotificationsAppInstaller, logsDrilldownAppInstaller, annotationAppInstaller, exampleAppInstaller, advisorAppInstaller, alertingHistorianAppInstaller, quotasAppInstaller, dashValidatorAppInstaller)
|
||||
builderMetrics := builder.ProvideBuilderMetrics(registerer)
|
||||
backend := auditing.ProvideNoopBackend()
|
||||
policyRuleProvider := auditing.ProvideNoopPolicyRuleProvider()
|
||||
@@ -1493,7 +1498,11 @@ func InitializeForTest(ctx context.Context, t sqlutil.ITestDB, testingT interfac
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, appInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller, alertingNotificationsAppInstaller, logsDrilldownAppInstaller, annotationAppInstaller, exampleAppInstaller, advisorAppInstaller, alertingHistorianAppInstaller, quotasAppInstaller)
|
||||
dashValidatorAppInstaller, err := dashvalidator.RegisterAppInstaller(service15, plugincontextProvider)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2 := appregistry.ProvideAppInstallers(featureToggles, playlistAppInstaller, appInstaller, shortURLAppInstaller, alertingRulesAppInstaller, correlationsAppInstaller, alertingNotificationsAppInstaller, logsDrilldownAppInstaller, annotationAppInstaller, exampleAppInstaller, advisorAppInstaller, alertingHistorianAppInstaller, quotasAppInstaller, dashValidatorAppInstaller)
|
||||
builderMetrics := builder.ProvideBuilderMetrics(registerer)
|
||||
backend := auditing.ProvideNoopBackend()
|
||||
policyRuleProvider := auditing.ProvideNoopPolicyRuleProvider()
|
||||
|
||||
Reference in New Issue
Block a user