Elasticsearch: Run requestAllIndices trough resource call if enableElasticsearchBackendQuerying enabled (#67825)

* Elasticsearch: Run requestAllIndices trough resource call if enabled

* Unlock resource call path

* Fix lint
This commit is contained in:
Ivana Huckova
2023-05-05 11:35:30 +02:00
committed by GitHub
parent 20217db100
commit f5ac099907
3 changed files with 184 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import (
"net/url"
"path"
"strconv"
"strings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
@@ -182,7 +183,8 @@ func (s *Service) CallResource(ctx context.Context, req *backend.CallResourceReq
logger := eslog.FromContext(ctx)
// allowed paths for resource calls:
// - empty string for fetching db version
if req.Path != "" {
// - /?/_mapping for fetching index mapping
if req.Path != "" && !strings.HasSuffix(req.Path, "/_mapping") {
return fmt.Errorf("invalid resource URL: %s", req.Path)
}