From b3b3de9d89eeba25f7d36ca84d12c2ba14813b08 Mon Sep 17 00:00:00 2001 From: Xiao Liu <46879761+liangzai006@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:44:50 +0800 Subject: [PATCH] change api default limit to result max --- pkg/controllers/inspectresult_controller.go | 1 + pkg/inspect/nodeinfo_inspect.go | 7 +++---- pkg/server/query/query.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/controllers/inspectresult_controller.go b/pkg/controllers/inspectresult_controller.go index 75ff3e38..74e1b1eb 100644 --- a/pkg/controllers/inspectresult_controller.go +++ b/pkg/controllers/inspectresult_controller.go @@ -173,6 +173,7 @@ func (r *InspectResultReconciler) CountLevelNum(resultName string) (map[kubeeyev ComputeLevel(result.Spec.PrometheusResult, levelTotal) ComputeLevel(result.Spec.ComponentResult, levelTotal) + ComputeLevel(result.Spec.CommandResult, levelTotal) return levelTotal, nil } diff --git a/pkg/inspect/nodeinfo_inspect.go b/pkg/inspect/nodeinfo_inspect.go index 6a1e2382..236fa264 100644 --- a/pkg/inspect/nodeinfo_inspect.go +++ b/pkg/inspect/nodeinfo_inspect.go @@ -159,11 +159,10 @@ func (o *nodeInfoInspect) GetResult(runNodeName string, resultCm *corev1.ConfigM return nil, err } - for _, item := range nodeInfoResult { - item.NodeName = runNodeName - resultCr.Spec.NodeInfo = append(resultCr.Spec.NodeInfo, item) + for i := range nodeInfoResult { + nodeInfoResult[i].NodeName = runNodeName } - + resultCr.Spec.NodeInfo = nodeInfoResult return resultCr, nil } diff --git a/pkg/server/query/query.go b/pkg/server/query/query.go index 46b83a9a..de85a522 100644 --- a/pkg/server/query/query.go +++ b/pkg/server/query/query.go @@ -73,7 +73,7 @@ func ParseQuery(g *gin.Context) *Query { func NewQuery() *Query { return &Query{ Pagination: &Pagination{ - Limit: 10, + Limit: 0, Offset: 0, }, SortBy: "", @@ -123,7 +123,7 @@ func ParsePagination(values url.Values) *Pagination { if limit != "" { atoi, err := strconv.Atoi(limit) if err != nil || atoi < 1 { - atoi = 10 + atoi = 0 } pagination.Limit = atoi } @@ -170,7 +170,7 @@ func (p *Pagination) computeIndex(total int) (int, int) { startIndex = p.Offset endIndex = startIndex + p.Limit - if endIndex > total { + if endIndex > total || endIndex == 0 { endIndex = total } if startIndex > total {