Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api-server): dataplane overview pagination #7803

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/api-server/dataplane_overview_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ func (r *dataplaneOverviewEndpoints) inspectDataplanes(request *restful.Request,
return
}

// pagination is not supported yet so we need to override pagination total items after retaining dataplanes
overviews.GetPagination().SetTotal(uint32(len(overviews.Items)))
restList := rest.From.ResourceList(&overviews)
restList.Next = nextLink(request, overviews.GetPagination().NextOffset)
if err := response.WriteAsJson(restList); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/api-server/dataplane_overview_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,17 @@ var _ = Describe("Dataplane Overview Endpoints", func() {
expectedJson: fmt.Sprintf(`{"total": 2, "items": [%s, %s], "next": null}`, gatewayBuiltinJson, gatewayDelegatedJson),
}),
)

It("should paginate correctly", func() {
// when
response, err := http.Get("http://" + apiServer.Address() + "/meshes/mesh1/dataplanes+insights?size=1")
Expect(err).ToNot(HaveOccurred())

// then
Expect(response.StatusCode).To(Equal(200))
body, err := io.ReadAll(response.Body)
Expect(err).ToNot(HaveOccurred())
Expect(string(body)).To(MatchJSON(fmt.Sprintf(`{"total": 3, "items": [%s], "next": "http://%s/meshes/mesh1/dataplanes+insights?offset=1&size=1"}`, dp1Json, apiServer.Address())))
})
})
})