grafana/pkg/setting/setting_unified_storage.go
Leonor Oliveira 2e451b2ed7
Use dw dynamic config (#91882)
* Remove kubernetesPlaylists feature_toggle

* Remove unified_storage_mode

* Remove double import

* Read from config instead from feature_toggle

* cover scenario for when unified storage is not defined

* Be temporarily retro compatible with previous feature toggle

* Properly read unified_storage section

* [WIP] Read new format of config

* Fix test

* Fix other tests

* Generate feature flags file

* Use <group>.<resource> schema

* Use <group>.resource format on the FE as well

* Hide UniStore config from Frontend

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* unwanted changes

* Use feature toggles in the FE. Enforce FTs are present before enabling dual writing
Co-authored-by: Ryan McKinley <ryantxu@users.noreply.github.com>

* use kubernetes playlists feature toggle on the FE

* Remove unwanted code

* Remove configs from the FE

* Remove commented code

* Add more explicit example

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: Maicon Costa <maiconscosta@gmail.com>
2024-08-30 11:59:42 +02:00

32 lines
934 B
Go

package setting
import (
"strings"
"github.com/grafana/grafana/pkg/apiserver/rest"
)
// read storage configs from ini file. They look like:
// [unified_storage.<group>.<resource>]
// <field> = <value>
// e.g.
// [unified_storage.playlists.playlist.grafana.app]
// dualWriterMode = 2
func (cfg *Cfg) setUnifiedStorageConfig() {
storageConfig := make(map[string]UnifiedStorageConfig)
sections := cfg.Raw.Sections()
for _, section := range sections {
sectionName := section.Name()
if !strings.HasPrefix(sectionName, "unified_storage.") {
continue
}
// the resource name is the part after the first dot
resourceName := strings.SplitAfterN(sectionName, ".", 2)[1]
// parse dualWriter modes from the section
dualWriterMode := section.Key("dualWriterMode").MustInt(0)
storageConfig[resourceName] = UnifiedStorageConfig{DualWriterMode: rest.DualWriterMode(dualWriterMode)}
}
cfg.UnifiedStorage = storageConfig
}