mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: Dashboards: Fix search parsing (#98560)
This commit is contained in:
parent
69af0f7ab6
commit
c566e6af4e
@ -310,7 +310,13 @@ func (s *SearchHandler) DoSearch(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
s.write(w, dashboardsvc.ParseResults(result, searchRequest.Offset))
|
||||
parsedResults, err := dashboardsvc.ParseResults(result, searchRequest.Offset)
|
||||
if err != nil {
|
||||
errhttp.Write(ctx, err, w)
|
||||
return
|
||||
}
|
||||
|
||||
s.write(w, parsedResults)
|
||||
}
|
||||
|
||||
func (s *SearchHandler) write(w http.ResponseWriter, obj any) {
|
||||
|
@ -1360,7 +1360,7 @@ func (dr *DashboardServiceImpl) searchDashboardsThroughK8sRaw(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ParseResults(res, 0), nil
|
||||
return ParseResults(res, 0)
|
||||
}
|
||||
|
||||
func (dr *DashboardServiceImpl) searchDashboardsThroughK8s(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) ([]*dashboards.Dashboard, error) {
|
||||
@ -1382,9 +1382,13 @@ func (dr *DashboardServiceImpl) searchDashboardsThroughK8s(ctx context.Context,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func ParseResults(result *resource.ResourceSearchResponse, offset int64) *v0alpha1.SearchResults {
|
||||
func ParseResults(result *resource.ResourceSearchResponse, offset int64) (*v0alpha1.SearchResults, error) {
|
||||
if result == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
} else if result.Error != nil {
|
||||
return nil, fmt.Errorf("%d error searching: %s: %s", result.Error.Code, result.Error.Message, result.Error.Details)
|
||||
} else if result.Results == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
titleIDX := 0
|
||||
@ -1455,7 +1459,7 @@ func ParseResults(result *resource.ResourceSearchResponse, offset int64) *v0alph
|
||||
}
|
||||
}
|
||||
|
||||
return sr
|
||||
return sr, nil
|
||||
}
|
||||
|
||||
func (dr *DashboardServiceImpl) UnstructuredToLegacyDashboard(ctx context.Context, item *unstructured.Unstructured, orgID int64) (*dashboards.Dashboard, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user