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:
Wang Yan 2024-10-24 14:13:58 +08:00 committed by GitHub
parent 610cc0a16c
commit e8722c06e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -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},
} }
} }

View File

@ -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