Compare commits

...

2 Commits

Author SHA1 Message Date
Charandas Batra
327880d79b fix build 2025-11-06 18:46:27 -08:00
Charandas Batra
8dccb73654 AppInstaller: POC changes to support dynamic lookup of FF in proxy handler 2025-11-06 18:40:43 -08:00
5 changed files with 39 additions and 38 deletions

View File

@@ -42,36 +42,37 @@ func ProvideAppInstallers(
logsdrilldownAppInstaller *logsdrilldown.LogsDrilldownAppInstaller,
annotationAppInstaller *annotation.AnnotationAppInstaller,
exampleAppInstaller *example.ExampleAppInstaller,
) []appsdkapiserver.AppInstaller {
installers := []appsdkapiserver.AppInstaller{
playlistAppInstaller,
pluginsApplInstaller,
exampleAppInstaller,
}
//nolint:staticcheck // not yet migrated to OpenFeature
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesShortURLs) {
installers = append(installers, shorturlAppInstaller)
}
//nolint:staticcheck // not yet migrated to OpenFeature
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesAlertingRules) && rulesAppInstaller != nil {
installers = append(installers, rulesAppInstaller)
}
//nolint:staticcheck // not yet migrated to OpenFeature
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesCorrelations) {
installers = append(installers, correlationsAppInstaller)
) map[string]appsdkapiserver.AppInstaller {
installers := map[string]appsdkapiserver.AppInstaller{
"ENABLED_PLAYLISTS": playlistAppInstaller,
"ENABLED_PLUGINS": pluginsApplInstaller,
"ENABLED_EXAMPLE_APP": exampleAppInstaller,
}
//if features.IsEnabledGlobally(featuremgmt.FlagKubernetesShortURLs) {
installers[featuremgmt.FlagKubernetesShortURLs] = shorturlAppInstaller
// }
// if features.IsEnabledGlobally(featuremgmt.FlagKubernetesAlertingRules) && rulesAppInstaller != nil {
installers[featuremgmt.FlagKubernetesAlertingRules] = rulesAppInstaller
// }
// if features.IsEnabledGlobally(featuremgmt.FlagKubernetesCorrelations) {
installers[featuremgmt.FlagKubernetesCorrelations] = correlationsAppInstaller
// }
// TODO: what to do about an installer that is not dynamic, maybe they should be on a different map than the one I made
if alertingNotificationAppInstaller != nil {
installers = append(installers, alertingNotificationAppInstaller)
}
//nolint:staticcheck // not yet migrated to OpenFeature
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesLogsDrilldown) {
installers = append(installers, logsdrilldownAppInstaller)
}
//nolint:staticcheck
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesAnnotations) {
installers = append(installers, annotationAppInstaller)
installers["ENABLED_ALERTING_NOTIFICATIONS"] = alertingNotificationAppInstaller
}
// if features.IsEnabledGlobally(featuremgmt.FlagKubernetesLogsDrilldown) {
installers[featuremgmt.FlagKubernetesLogsDrilldown] = logsdrilldownAppInstaller
// }
// if features.IsEnabledGlobally(featuremgmt.FlagKubernetesAnnotations) {
installers[featuremgmt.FlagKubernetesAnnotations] = annotationAppInstaller
// }
return installers
}

View File

@@ -54,7 +54,7 @@ type serverLock interface {
// AddToScheme adds app installer schemas to the runtime scheme
func AddToScheme(
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
scheme *runtime.Scheme,
) ([]schema.GroupVersion, error) {
var additionalGroupVersions []schema.GroupVersion
@@ -70,7 +70,7 @@ func AddToScheme(
// RegisterAdmission combines the existing admission control from builders.
func RegisterAdmission(
existingAdmission admission.Interface,
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
) (admission.Interface, error) {
controllers := []admission.Interface{}
@@ -100,7 +100,7 @@ type AuthorizerRegistrar interface {
func RegisterAuthorizers(
ctx context.Context,
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
registrar AuthorizerRegistrar,
) {
logger := logging.FromContext(ctx)
@@ -116,7 +116,7 @@ func RegisterAuthorizers(
}
func BuildOpenAPIDefGetter(
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
) func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
return func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
defs := make(map[string]common.OpenAPIDefinition)
@@ -130,7 +130,7 @@ func BuildOpenAPIDefGetter(
func InstallAPIs(
ctx context.Context,
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
server *genericapiserver.GenericAPIServer,
restOpsGetter generic.RESTOptionsGetter,
storageOpts *grafanaapiserveroptions.StorageOptions,
@@ -169,7 +169,7 @@ func InstallAPIs(
// RegisterPostStartHooks registers individual post start hooks for each app installer
func RegisterPostStartHooks(
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
serverConfig *genericapiserver.RecommendedConfig,
) error {
for _, installer := range appInstallers {

View File

@@ -6,7 +6,7 @@ import (
serverstorage "k8s.io/apiserver/pkg/server/storage"
)
func NewAPIResourceConfig(installers []appsdkapiserver.AppInstaller) *serverstorage.ResourceConfig {
func NewAPIResourceConfig(installers map[string]appsdkapiserver.AppInstaller) *serverstorage.ResourceConfig {
ret := serverstorage.NewResourceConfig()
enable := []schema.GroupVersion{}
disable := []schema.GroupVersion{}

View File

@@ -114,7 +114,7 @@ type APIRoutes struct {
type APIRegistrar interface {
RegisterAPI(builder APIGroupBuilder)
RegisterAppInstaller(installer appsdkapiserver.AppInstaller)
RegisterAppInstaller(featureFlag string, installer appsdkapiserver.AppInstaller)
}
func getGroup(builder APIGroupBuilder) (string, error) {

View File

@@ -110,7 +110,7 @@ type service struct {
buildHandlerChainFuncFromBuilders builder.BuildHandlerChainFuncFromBuilders
aggregatorRunner aggregatorrunner.AggregatorRunner
appInstallers []appsdkapiserver.AppInstaller
appInstallers map[string]appsdkapiserver.AppInstaller
builderMetrics *builder.BuilderMetrics
dualWriterMetrics *grafanarest.DualWriterMetrics
}
@@ -135,7 +135,7 @@ func ProvideService(
eventualRestConfigProvider *eventualRestConfigProvider,
reg prometheus.Registerer,
aggregatorRunner aggregatorrunner.AggregatorRunner,
appInstallers []appsdkapiserver.AppInstaller,
appInstallers map[string]appsdkapiserver.AppInstaller,
builderMetrics *builder.BuilderMetrics,
) (*service, error) {
scheme := builder.ProvideScheme()
@@ -248,8 +248,8 @@ func (s *service) RegisterAPI(b builder.APIGroupBuilder) {
s.builders = append(s.builders, b)
}
func (s *service) RegisterAppInstaller(i appsdkapiserver.AppInstaller) {
s.appInstallers = append(s.appInstallers, i)
func (s *service) RegisterAppInstaller(featureFlag string, i appsdkapiserver.AppInstaller) {
s.appInstallers[featureFlag] = i
}
// nolint:gocyclo