mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 02:05:41 +01:00
add pagesize for replicaiton (#21081)
fixes #20430, set the pagesize to 100 when to list artifact on replication Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
610cc0a16c
commit
e8722c06e9
@ -32,7 +32,7 @@ var _ adp.ArtifactRegistry = &adapter{}
|
|||||||
func New(base *base.Adapter) adp.Adapter {
|
func New(base *base.Adapter) adp.Adapter {
|
||||||
return &adapter{
|
return &adapter{
|
||||||
Adapter: base,
|
Adapter: base,
|
||||||
client: &client{Client: base.Client},
|
client: &client{Client: base.Client, pageSize: 100},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
*base.Client
|
*base.Client
|
||||||
|
pageSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) listRepositories(project *base.Project) ([]*model.Repository, error) {
|
func (c *client) listRepositories(project *base.Project) ([]*model.Repository, error) {
|
||||||
@ -51,8 +52,12 @@ func (c *client) listRepositories(project *base.Project) ([]*model.Repository, e
|
|||||||
func (c *client) listArtifacts(repo string) ([]*model.Artifact, error) {
|
func (c *client) listArtifacts(repo string) ([]*model.Artifact, error) {
|
||||||
project, repo := utils.ParseRepository(repo)
|
project, repo := utils.ParseRepository(repo)
|
||||||
repo = repository.Encode(repo)
|
repo = repository.Encode(repo)
|
||||||
url := fmt.Sprintf("%s/projects/%s/repositories/%s/artifacts?with_label=true&with_accessory=true",
|
// set the default value to equal the value specified when the UI submits the request
|
||||||
c.BasePath(), project, repo)
|
if c.pageSize == 0 {
|
||||||
|
c.pageSize = 15
|
||||||
|
}
|
||||||
|
url := fmt.Sprintf("%s/projects/%s/repositories/%s/artifacts?page_size=%d&with_label=true&with_accessory=true",
|
||||||
|
c.BasePath(), project, repo, c.pageSize)
|
||||||
artifacts := []*artifact.Artifact{}
|
artifacts := []*artifact.Artifact{}
|
||||||
if err := c.C.GetAndIteratePagination(url, &artifacts); err != nil {
|
if err := c.C.GetAndIteratePagination(url, &artifacts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user