Enable errcheck for golangci-lint (#19976)

* Enable `errcheck` for golangci-lint
* Fix linting errors
* pkg/plugins: Fix tests
* pkg/plugins: Add test
This commit is contained in:
Arve Knudsen
2019-10-28 17:25:35 +01:00
committed by GitHub
parent 9e004b9211
commit f9774acc4c
4 changed files with 56 additions and 18 deletions
+5 -4
View File
@@ -10,6 +10,7 @@ import (
"time"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/errutil"
datasourceV1 "github.com/grafana/grafana-plugin-model/go/datasource"
sdk "github.com/grafana/grafana-plugin-sdk-go"
@@ -46,16 +47,16 @@ type DataSourcePlugin struct {
}
func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error {
if err := decoder.Decode(&p); err != nil {
return err
if err := decoder.Decode(p); err != nil {
return errutil.Wrapf(err, "Failed to decode datasource plugin")
}
if !p.isVersionOne() && !setting.IsExpressionsEnabled() {
return errors.New("A plugin version 2 was found but expressions feature toggle is not enabled")
return errors.New("A plugin version 2 was found, but expressions feature toggle is not enabled")
}
if err := p.registerPlugin(pluginDir); err != nil {
return err
return errutil.Wrapf(err, "Failed to register plugin")
}
DataSources[p.Id] = p