Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
50faeb30
Unverified
Commit
50faeb30
authored
Feb 15, 2021
by
Torkel Ödegaard
Committed by
GitHub
Feb 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataSourceSrv: Filter out non queryable data sources by default (#31144)
parent
0c3c1759
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
packages/grafana-runtime/src/services/dataSourceSrv.ts
+19
-0
public/app/features/plugins/datasource_srv.ts
+9
-0
public/app/features/plugins/specs/datasource_srv.test.ts
+13
-0
No files found.
packages/grafana-runtime/src/services/dataSourceSrv.ts
View file @
50faeb30
...
...
@@ -28,12 +28,31 @@ export interface DataSourceSrv {
/** @public */
export
interface
GetDataSourceListFilters
{
/** Include mixed deta source by setting this to true */
mixed
?:
boolean
;
/** Only return data sources that support metrics response */
metrics
?:
boolean
;
/** Only return data sources that support tracing response */
tracing
?:
boolean
;
/** Only return data sources that support annotations */
annotations
?:
boolean
;
/**
* By default only data sources that can be queried will be returned. Meaning they have tracing,
* metrics, logs or annotations flag set in plugin.json file
* */
all
?:
boolean
;
/** Set to true to return dashboard data source */
dashboard
?:
boolean
;
/** Set to true to return data source variables */
variables
?:
boolean
;
/** filter list by plugin */
pluginId
?:
string
;
}
...
...
public/app/features/plugins/datasource_srv.ts
View file @
50faeb30
...
...
@@ -157,6 +157,15 @@ export class DatasourceSrv implements DataSourceService {
if
(
filters
.
pluginId
&&
x
.
meta
.
id
!==
filters
.
pluginId
)
{
return
false
;
}
if
(
!
filters
.
all
&&
x
.
meta
.
metrics
!==
true
&&
x
.
meta
.
annotations
!==
true
&&
x
.
meta
.
tracing
!==
true
&&
x
.
meta
.
logs
!==
true
)
{
return
false
;
}
return
true
;
});
...
...
public/app/features/plugins/specs/datasource_srv.test.ts
View file @
50faeb30
...
...
@@ -75,6 +75,12 @@ describe('datasource_srv', () => {
uid
:
'uid-code-Jaeger'
,
meta
:
{
tracing
:
true
,
id
:
'jaeger'
},
},
CannotBeQueried
:
{
type
:
'no-query'
,
name
:
'no-query'
,
uid
:
'no-query'
,
meta
:
{
id
:
'no-query'
},
},
};
describe
(
'Given a list of data sources'
,
()
=>
{
...
...
@@ -120,6 +126,13 @@ describe('datasource_srv', () => {
});
});
it
(
'Should by default filter out data sources that cannot be queried'
,
()
=>
{
const
list
=
dataSourceSrv
.
getList
({});
expect
(
list
.
find
((
x
)
=>
x
.
name
===
'no-query'
)).
toBeUndefined
();
const
all
=
dataSourceSrv
.
getList
({
all
:
true
});
expect
(
all
.
find
((
x
)
=>
x
.
name
===
'no-query'
)).
toBeDefined
();
});
it
(
'Can get list of data sources with variables: true'
,
()
=>
{
const
list
=
dataSourceSrv
.
getList
({
metrics
:
true
,
variables
:
true
});
expect
(
list
[
0
].
name
).
toBe
(
'${datasource}'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment