2017-04-11 17:06:45 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
2021-09-27 17:51:55 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
2017-04-11 17:06:45 +00:00
|
|
|
)
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
type db struct {
|
2017-04-11 17:06:45 +00:00
|
|
|
store model.RegistryStore
|
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new local registry service.
|
|
|
|
func New(store model.RegistryStore) model.RegistryService {
|
2020-05-19 12:44:16 +00:00
|
|
|
return &db{store}
|
2017-04-11 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
func (b *db) RegistryFind(repo *model.Repo, name string) (*model.Registry, error) {
|
2017-04-11 17:06:45 +00:00
|
|
|
return b.store.RegistryFind(repo, name)
|
|
|
|
}
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
func (b *db) RegistryList(repo *model.Repo) ([]*model.Registry, error) {
|
2017-04-11 17:06:45 +00:00
|
|
|
return b.store.RegistryList(repo)
|
|
|
|
}
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
func (b *db) RegistryCreate(repo *model.Repo, in *model.Registry) error {
|
2017-04-11 17:06:45 +00:00
|
|
|
return b.store.RegistryCreate(in)
|
|
|
|
}
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
func (b *db) RegistryUpdate(repo *model.Repo, in *model.Registry) error {
|
2017-04-11 17:06:45 +00:00
|
|
|
return b.store.RegistryUpdate(in)
|
|
|
|
}
|
|
|
|
|
2020-05-19 12:44:16 +00:00
|
|
|
func (b *db) RegistryDelete(repo *model.Repo, addr string) error {
|
2017-04-11 17:06:45 +00:00
|
|
|
registry, err := b.RegistryFind(repo, addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return b.store.RegistryDelete(registry)
|
|
|
|
}
|