MCPcopy Index your code
hub / github.com/1Panel-dev/KubePi / pagerAndSearch

Function pagerAndSearch

internal/api/v1/proxy/proxy.go:202–225  ·  view source on GitHub ↗
(ctx *context.Context, listObj K8sListObj, keywords string)

Source from the content-addressed store, hash-verified

200var timeTemplate = "2006-01-02T15:04:05Z"
201
202func pagerAndSearch(ctx *context.Context, listObj K8sListObj, keywords string) (*pkgV1.Page, error) {
203 num, err1 := ctx.Values().GetInt("pageNum")
204 size, err2 := ctx.Values().GetInt("pageSize")
205 var p pkgV1.Page
206 if listObj.Kind != "NodeList" {
207 listObj.Sort()
208 }
209 if keywords != "" {
210 listObj.Items = fieldFilter(listObj.Items, withNamespaceAndNameMatcher(keywords))
211 }
212 if err1 == nil && err2 == nil {
213 tt, items, err := pageFilter(num, size, listObj.Items)
214 if err != nil {
215 return nil, err
216 }
217 listObj.Items = items
218 p.Total = tt
219 p.Items = listObj.Items
220 return &p, nil
221 }
222 p.Total = len(listObj.Items)
223 p.Items = listObj.Items
224 return &p, nil
225}
226
227func getTime(obj interface{}) time.Time {
228 //判断是否存在lasttime

Callers 1

KubernetesAPIProxyMethod · 0.85

Calls 4

fieldFilterFunction · 0.85
pageFilterFunction · 0.85
SortMethod · 0.80

Tested by

no test coverage detected