mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
43f40e6c7c
* replace yaml.v2 with yaml.v3 * fix a few tests due to the yaml.v3 api changes * and another goconvey mistake in tests
35 lines
709 B
Go
35 lines
709 B
Go
package featuremgmt
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type configBody struct {
|
|
// define variables that can be used in expressions
|
|
Vars map[string]interface{} `yaml:"vars"`
|
|
|
|
// Define and override feature flag properties
|
|
Flags []FeatureFlag `yaml:"flags"`
|
|
|
|
// keep track of where the fie was loaded from
|
|
filename string
|
|
}
|
|
|
|
// will read a single configfile
|
|
func readConfigFile(filename string) (*configBody, error) {
|
|
cfg := &configBody{}
|
|
|
|
// Can ignore gosec G304 because the file path is forced within config subfolder
|
|
//nolint:gosec
|
|
yamlFile, err := os.ReadFile(filename)
|
|
if err != nil {
|
|
return cfg, err
|
|
}
|
|
|
|
err = yaml.Unmarshal(yamlFile, cfg)
|
|
cfg.filename = filename
|
|
return cfg, err
|
|
}
|