@ -46,6 +46,7 @@ import (
"github.com/grafana/grafana/pkg/services/publicdashboards"
"github.com/grafana/grafana/pkg/services/quota"
"github.com/grafana/grafana/pkg/services/search/model"
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
"github.com/grafana/grafana/pkg/services/store/entity"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
@ -232,7 +233,7 @@ func (dr *DashboardServiceImpl) GetProvisionedDashboardData(ctx context.Context,
for _ , org := range orgs {
func ( orgID int64 ) {
g . Go ( func ( ) error {
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , dashboards . FindPersistedDashboardsQuery {
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , & dashboards . FindPersistedDashboardsQuery {
ProvisionedRepo : name ,
OrgId : orgID ,
} )
@ -273,7 +274,7 @@ func (dr *DashboardServiceImpl) GetProvisionedDashboardDataByDashboardID(ctx con
}
for _ , org := range orgs {
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , dashboards . FindPersistedDashboardsQuery {
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , & dashboards . FindPersistedDashboardsQuery {
OrgId : org . ID ,
DashboardIds : [ ] int64 { dashboardID } ,
} )
@ -300,7 +301,7 @@ func (dr *DashboardServiceImpl) GetProvisionedDashboardDataByDashboardUID(ctx co
return nil , nil
}
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , dashboards . FindPersistedDashboardsQuery {
res , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , & dashboards . FindPersistedDashboardsQuery {
OrgId : orgID ,
DashboardUIDs : [ ] string { dashboardUID } ,
} )
@ -559,7 +560,7 @@ func (dr *DashboardServiceImpl) DeleteOrphanedProvisionedDashboards(ctx context.
for _ , org := range orgs {
ctx , _ := identity . WithServiceIdentity ( ctx , org . ID )
// find all dashboards in the org that have a file repo set that is not in the given readers list
foundDashs , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , dashboards . FindPersistedDashboardsQuery {
foundDashs , err := dr . searchProvisionedDashboardsThroughK8s ( ctx , & dashboards . FindPersistedDashboardsQuery {
ProvisionedReposNotIn : cmd . ReaderNames ,
OrgId : org . ID ,
} )
@ -1436,7 +1437,12 @@ func (dr *DashboardServiceImpl) DeleteInFolders(ctx context.Context, orgID int64
}
// We need a list of dashboard uids inside the folder to delete related public dashboards
dashes , err := dr . dashboardStore . FindDashboards ( ctx , & dashboards . FindPersistedDashboardsQuery { SignedInUser : u , FolderUIDs : folderUIDs , OrgId : orgID } )
dashes , err := dr . dashboardStore . FindDashboards ( ctx , & dashboards . FindPersistedDashboardsQuery {
SignedInUser : u ,
FolderUIDs : folderUIDs ,
OrgId : orgID ,
Type : searchstore . TypeDashboard ,
} )
if err != nil {
return folder . ErrInternal . Errorf ( "failed to fetch dashboards: %w" , err )
}
@ -1729,7 +1735,11 @@ type dashboardProvisioningWithUID struct {
DashboardUID string
}
func ( dr * DashboardServiceImpl ) searchProvisionedDashboardsThroughK8s ( ctx context . Context , query dashboards . FindPersistedDashboardsQuery ) ( [ ] * dashboardProvisioningWithUID , error ) {
func ( dr * DashboardServiceImpl ) searchProvisionedDashboardsThroughK8s ( ctx context . Context , query * dashboards . FindPersistedDashboardsQuery ) ( [ ] * dashboardProvisioningWithUID , error ) {
if query == nil {
return nil , errors . New ( "query cannot be nil" )
}
ctx , _ = identity . WithServiceIdentity ( ctx , query . OrgId )
if query . ProvisionedRepo != "" {
@ -1744,7 +1754,9 @@ func (dr *DashboardServiceImpl) searchProvisionedDashboardsThroughK8s(ctx contex
query . ProvisionedReposNotIn = repos
}
searchResults , err := dr . searchDashboardsThroughK8sRaw ( ctx , & query )
query . Type = searchstore . TypeDashboard
searchResults , err := dr . searchDashboardsThroughK8sRaw ( ctx , query )
if err != nil {
return nil , err
}
@ -1807,6 +1819,11 @@ func (dr *DashboardServiceImpl) searchProvisionedDashboardsThroughK8s(ctx contex
}
func ( dr * DashboardServiceImpl ) searchDashboardsThroughK8s ( ctx context . Context , query * dashboards . FindPersistedDashboardsQuery ) ( [ ] * dashboards . Dashboard , error ) {
if query == nil {
return nil , errors . New ( "query cannot be nil" )
}
query . Type = searchstore . TypeDashboard
response , err := dr . searchDashboardsThroughK8sRaw ( ctx , query )
if err != nil {
return nil , err