PublicDashboards: Added grafana special datasources to supported list (#64930)

This commit is contained in:
Ezequiel Victorero
2023-03-17 13:14:24 -03:00
committed by GitHub
parent 529ffe61e7
commit e01a3e0ea5
6 changed files with 28 additions and 4 deletions

View File

@@ -6,8 +6,12 @@ import (
"net/http"
"sort"
"sync"
"github.com/grafana/grafana/pkg/expr"
)
var grafanaDatasources = []string{expr.DatasourceType, "datasource"}
type listPluginResponse struct {
Items []struct {
Slug string `json:"slug"`
@@ -41,6 +45,8 @@ func GetCompatibleDatasources(baseUrl string) ([]string, error) {
}
}
supported = append(supported, grafanaDatasources...)
sort.Strings(supported)
return supported, nil
}

View File

@@ -13,7 +13,7 @@ import (
var tsDatasourcesTemplate = `
// Code generated by go generate; DO NOT EDIT.
export const supportedDatasources = new Set<string>([
export const supportedDatasources = new Set<string>([
{{- range . }}
'{{ printf "%s" . }}',
{{- end }}

View File

@@ -3,6 +3,7 @@ package generate_datasources
import (
"net/http"
"net/http/httptest"
"sort"
"testing"
"github.com/stretchr/testify/assert"
@@ -31,6 +32,14 @@ func TestCanGetCompatibleDatasources(t *testing.T) {
datasources, err := GetCompatibleDatasources(server.URL)
require.NoError(t, err)
assert.Len(t, datasources, 1)
assert.Equal(t, "postgres", datasources[0])
expectedDatasources := []string{"postgres"}
expectedDatasources = append(expectedDatasources, grafanaDatasources...)
sort.Strings(expectedDatasources)
assert.Len(t, datasources, len(expectedDatasources))
for i := range expectedDatasources {
assert.Equal(t, expectedDatasources[i], datasources[i])
}
}

View File

@@ -254,7 +254,7 @@ func (_m *FakePublicDashboardService) FindDashboard(ctx context.Context, orgId i
return r0, r1
}
// FindEnabledDashboardAndDashboardByAccessToken provides a mock function with given fields: ctx, accessToken
// FindEnabledPublicDashboardAndDashboardByAccessToken provides a mock function with given fields: ctx, accessToken
func (_m *FakePublicDashboardService) FindEnabledPublicDashboardAndDashboardByAccessToken(ctx context.Context, accessToken string) (*models.PublicDashboard, *dashboards.Dashboard, error) {
ret := _m.Called(ctx, accessToken)