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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)

View File

@ -56,6 +56,12 @@ describe('getUnsupportedDashboardDatasources', () => {
{
datasource: { type: 'prometheus' } as DataSourceRef,
} as DataQuery,
{
datasource: { type: '__expr__' } as DataSourceRef,
} as DataQuery,
{
datasource: { type: 'datasource' } as DataSourceRef,
} as DataQuery,
] as DataQuery[],
} as PanelModel;
const panelArray: PanelModel[] = [pm];

View File

@ -1,8 +1,10 @@
// Code generated by go generate; DO NOT EDIT.
export const supportedDatasources = new Set<string>([
'__expr__',
'aquaqanalytics-kdbbackend-datasource',
'cloudwatch',
'datasource',
'dlopes7-appdynamics-datasource',
'doitintl-bigquery-datasource',
'elasticsearch',
@ -19,6 +21,7 @@ export const supportedDatasources = new Set<string>([
'grafana-dynatrace-datasource',
'grafana-es-open-distro-datasource',
'grafana-github-datasource',
'grafana-gitlab-datasource',
'grafana-honeycomb-datasource',
'grafana-iot-sitewise-datasource',
'grafana-jira-datasource',