goharbor / go-client

Client library with golang for accessing Harbor API.
Apache License 2.0
39 stars 18 forks source link

Pagination works unexpected #12

Open EugenMayer opened 2 years ago

EugenMayer commented 2 years ago

Assuming one has 360 artifacts and uses ListArtifacts to fetch them with a maximum page size of 100, so

    params := artifact.ListArtifactsParams{
        Page:           page,
        PageSize:       100,
        ProjectName:  "myproject",
        RepositoryName: "myimage"
    }

We should assume to fetch 4 pages, while the last page only includes 60 artifacts. In fact, the last page includes 100 artifacts instead.

We start with page 0 end end up page 3, fetching 4x100, instead of 3x100+1x60

EugenMayer commented 2 years ago

After fiddling around i happened to notice that a page should start at 1 for harbor (kind of unusual in the technical space), and that was the reason.

Far more interesting on top of that is, that page:0 also returns a result, not sure this is deterministic at all