mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 17:02:20 +08:00

--------- Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com> Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com> Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
37 lines
872 B
Go
37 lines
872 B
Go
package dashboard
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
|
"github.com/grafana/grafana/pkg/services/datasources"
|
|
)
|
|
|
|
type datasourceInfoProvider struct {
|
|
datasourceService datasources.DataSourceService
|
|
}
|
|
|
|
func (d *datasourceInfoProvider) GetDataSourceInfo() []schemaversion.DataSourceInfo {
|
|
query := datasources.GetAllDataSourcesQuery{}
|
|
dataSources, err := d.datasourceService.GetAllDataSources(context.Background(), &query)
|
|
|
|
if err != nil {
|
|
return []schemaversion.DataSourceInfo{}
|
|
}
|
|
|
|
out := make([]schemaversion.DataSourceInfo, 0, len(dataSources))
|
|
|
|
for _, ds := range dataSources {
|
|
out = append(out, schemaversion.DataSourceInfo{
|
|
Name: ds.Name,
|
|
UID: ds.UID,
|
|
ID: ds.ID,
|
|
Type: ds.Type,
|
|
Default: ds.IsDefault,
|
|
APIVersion: ds.APIVersion,
|
|
})
|
|
}
|
|
|
|
return out
|
|
}
|