Migrate to Wire for dependency injection (#32289)
Fixes #30144 Co-authored-by: dsotirakis <sotirakis.dim@gmail.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com> Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Leon Sorokin <leeoniya@gmail.com> Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com> Co-authored-by: spinillos <selenepinillos@gmail.com> Co-authored-by: Karl Persson <kalle.persson@grafana.com> Co-authored-by: Leonard Gram <leo@xlson.com>
This commit is contained in:
co-authored by
dsotirakis
Marcus Efraimsson
Ida Furjesova
Jack Westbrook
Will Browne
Leon Sorokin
Andrej Ocenas
spinillos
Karl Persson
Leonard Gram
parent
e61bc33163
commit
78596a6756
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
)
|
||||
|
||||
func (p *testDataPlugin) handleCsvContentScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
func (p *TestDataPlugin) handleCsvContentScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
resp := backend.NewQueryDataResponse()
|
||||
|
||||
for _, q := range req.Queries {
|
||||
@@ -43,7 +43,7 @@ func (p *testDataPlugin) handleCsvContentScenario(ctx context.Context, req *back
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *testDataPlugin) handleCsvFileScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
func (p *TestDataPlugin) handleCsvFileScenario(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
resp := backend.NewQueryDataResponse()
|
||||
|
||||
for _, q := range req.Queries {
|
||||
@@ -72,14 +72,14 @@ func (p *testDataPlugin) handleCsvFileScenario(ctx context.Context, req *backend
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *testDataPlugin) loadCsvFile(fileName string) (*data.Frame, error) {
|
||||
func (p *TestDataPlugin) loadCsvFile(fileName string) (*data.Frame, error) {
|
||||
validFileName := regexp.MustCompile(`([\w_]+)\.csv`)
|
||||
|
||||
if !validFileName.MatchString(fileName) {
|
||||
return nil, fmt.Errorf("invalid csv file name: %q", fileName)
|
||||
}
|
||||
|
||||
filePath := filepath.Join(p.Cfg.StaticRootPath, "testdata", fileName)
|
||||
filePath := filepath.Join(p.cfg.StaticRootPath, "testdata", fileName)
|
||||
|
||||
// Can ignore gosec G304 here, because we check the file pattern above
|
||||
// nolint:gosec
|
||||
@@ -97,7 +97,7 @@ func (p *testDataPlugin) loadCsvFile(fileName string) (*data.Frame, error) {
|
||||
return p.loadCsvContent(fileReader, fileName)
|
||||
}
|
||||
|
||||
func (p *testDataPlugin) loadCsvContent(ioReader io.Reader, name string) (*data.Frame, error) {
|
||||
func (p *TestDataPlugin) loadCsvContent(ioReader io.Reader, name string) (*data.Frame, error) {
|
||||
reader := csv.NewReader(ioReader)
|
||||
|
||||
// Read the header records
|
||||
|
||||
Reference in New Issue
Block a user