mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-20 08:51:01 +00:00
0f9188597e
- Add pagination support to the API endpoints that return lists of items - Adjust UI to enable infinite scrolling via pagination
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package registry
|
|
|
|
import (
|
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
|
)
|
|
|
|
type combined struct {
|
|
registries []model.ReadOnlyRegistryService
|
|
dbRegistry model.RegistryService
|
|
}
|
|
|
|
func Combined(dbRegistry model.RegistryService, registries ...model.ReadOnlyRegistryService) model.RegistryService {
|
|
registries = append(registries, dbRegistry)
|
|
return &combined{
|
|
registries: registries,
|
|
dbRegistry: dbRegistry,
|
|
}
|
|
}
|
|
|
|
func (c combined) RegistryFind(repo *model.Repo, name string) (*model.Registry, error) {
|
|
for _, registry := range c.registries {
|
|
res, err := registry.RegistryFind(repo, name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if res != nil {
|
|
return res, nil
|
|
}
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (c combined) RegistryList(repo *model.Repo, p *model.ListOptions) ([]*model.Registry, error) {
|
|
var registries []*model.Registry
|
|
for _, registry := range c.registries {
|
|
list, err := registry.RegistryList(repo, &model.ListOptions{All: true})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
registries = append(registries, list...)
|
|
}
|
|
return model.ApplyPagination(p, registries), nil
|
|
}
|
|
|
|
func (c combined) RegistryCreate(repo *model.Repo, registry *model.Registry) error {
|
|
return c.dbRegistry.RegistryCreate(repo, registry)
|
|
}
|
|
|
|
func (c combined) RegistryUpdate(repo *model.Repo, registry *model.Registry) error {
|
|
return c.dbRegistry.RegistryUpdate(repo, registry)
|
|
}
|
|
|
|
func (c combined) RegistryDelete(repo *model.Repo, name string) error {
|
|
return c.dbRegistry.RegistryDelete(repo, name)
|
|
}
|