Use dw dynamic config (#91222)

* Remove kubernetesPlaylists feature_toggle

* Remove unified_storage_mode

* Remove double import

* Regenerate feature-toggles

* Read from config instead from feature_toggle

* cover scenario for when unified storage is not defined
This commit is contained in:
Leonor Oliveira
2024-08-13 09:03:28 +01:00
committed by GitHub
parent b67bcdb9b8
commit 0258842f87
14 changed files with 31 additions and 70 deletions

View File

@@ -12,13 +12,12 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/apis/playlist/v0alpha1"
playlistalpha1 "github.com/grafana/grafana/pkg/apis/playlist/v0alpha1"
"github.com/grafana/grafana/pkg/middleware"
internalplaylist "github.com/grafana/grafana/pkg/registry/apis/playlist"
grafanaapiserver "github.com/grafana/grafana/pkg/services/apiserver"
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/playlist"
"github.com/grafana/grafana/pkg/util/errhttp"
"github.com/grafana/grafana/pkg/web"
@@ -27,7 +26,8 @@ import (
func (hs *HTTPServer) registerPlaylistAPI(apiRoute routing.RouteRegister) {
// Register the actual handlers
apiRoute.Group("/playlists", func(playlistRoute routing.RouteRegister) {
if hs.Features.IsEnabledGlobally(featuremgmt.FlagKubernetesPlaylists) {
unifiedStorageOptions := hs.Cfg.UnifiedStorage
if mode, ok := unifiedStorageOptions[playlistalpha1.GROUPRESOURCE]; ok && mode > 0 {
// Use k8s client to implement legacy API
handler := newPlaylistK8sHandler(hs)
playlistRoute.Get("/", handler.searchPlaylists)
@@ -330,7 +330,7 @@ type playlistK8sHandler struct {
func newPlaylistK8sHandler(hs *HTTPServer) *playlistK8sHandler {
return &playlistK8sHandler{
gvr: v0alpha1.PlaylistResourceInfo.GroupVersionResource(),
gvr: playlistalpha1.PlaylistResourceInfo.GroupVersionResource(),
namespacer: request.GetNamespaceMapper(hs.Cfg),
clientConfigProvider: hs.clientConfigProvider,
}