api: new v2 metrics query endpoint

Requests to endpoint will currently will error unless expressions feature flag is true.

Co-authored-by: Sofia Papagiannaki <papagian@gmail.com>
This commit is contained in:
Marcus Efraimsson
2019-10-25 09:28:26 -04:00
committed by Kyle Brandt
co-authored by Sofia Papagiannaki
parent 24183ba390
commit 771f21ed09
4 changed files with 76 additions and 10 deletions
+2 -10
View File
@@ -45,21 +45,13 @@ type DataSourcePlugin struct {
client *plugin.Client
}
func isExpressionsEnabled() bool {
v, ok := setting.FeatureToggles["expressions"]
if !ok {
return false
}
return v
}
func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error {
if err := decoder.Decode(&p); err != nil {
return err
}
if !p.isVersionOne() && !isExpressionsEnabled() {
return errors.New("A plugin version 2 was found but expressions feature toggle are not enabled")
if !p.isVersionOne() && !setting.IsExpressionsEnabled() {
return errors.New("A plugin version 2 was found but expressions feature toggle is not enabled")
}
if err := p.registerPlugin(pluginDir); err != nil {