From 45ef79795db799a6061551d1ded7f4dd9b4112cb Mon Sep 17 00:00:00 2001 From: zehuaiWANG <874697675@qq.com> Date: Tue, 3 Dec 2019 14:12:23 +0800 Subject: [PATCH] modified the resources --- pkg/models/resources/resources.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/models/resources/resources.go b/pkg/models/resources/resources.go index c1186648..d23fffd5 100644 --- a/pkg/models/resources/resources.go +++ b/pkg/models/resources/resources.go @@ -160,10 +160,13 @@ func ListResources(namespace, resource string, conditions *params.Conditions, or return nil, err } - for i, item := range result { - if i >= offset && (limit == -1 || len(items) < limit) { - items = append(items, injector.addExtraAnnotations(item)) - } + if limit == -1 || limit+offset > len(result) { + limit = len(result) - offset + } + + result = result[offset : offset+limit] + for _, item := range result { + items = append(items, injector.addExtraAnnotations(item)) } return &models.PageableResponse{TotalCount: len(result), Items: items}, nil -- GitLab