2021-05-08 22:25:31 +02:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
2024-10-26 14:56:17 +02:00
|
|
|
"github.com/semaphoreui/semaphore/db"
|
2021-05-08 22:25:31 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (d *BoltDb) GetRepository(projectID int, repositoryID int) (repository db.Repository, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObject(projectID, db.RepositoryProps, intObjectID(repositoryID), &repository)
|
2021-06-24 21:58:39 +02:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2021-09-10 00:41:36 +02:00
|
|
|
repository.SSHKey, err = d.GetAccessKey(projectID, repository.SSHKeyID)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-02-03 08:05:13 +01:00
|
|
|
func (d *BoltDb) GetRepositoryRefs(projectID int, repositoryID int) (db.ObjectReferrers, error) {
|
|
|
|
return d.getObjectRefs(projectID, db.RepositoryProps, repositoryID)
|
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) GetRepositories(projectID int, params db.RetrieveQueryParams) (repositories []db.Repository, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObjects(projectID, db.RepositoryProps, params, nil, &repositories)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) UpdateRepository(repository db.Repository) error {
|
2022-01-22 09:16:23 +01:00
|
|
|
err := repository.Validate()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.updateObject(repository.ProjectID, db.RepositoryProps, repository)
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) CreateRepository(repository db.Repository) (db.Repository, error) {
|
2022-01-22 09:16:23 +01:00
|
|
|
err := repository.Validate()
|
|
|
|
if err != nil {
|
|
|
|
return db.Repository{}, err
|
|
|
|
}
|
2021-05-13 21:45:54 +02:00
|
|
|
newRepo, err := d.createObject(repository.ProjectID, db.RepositoryProps, repository)
|
2021-05-08 22:25:31 +02:00
|
|
|
return newRepo.(db.Repository), err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteRepository(projectID int, repositoryId int) error {
|
2022-01-31 23:16:00 +01:00
|
|
|
return d.deleteObject(projectID, db.RepositoryProps, intObjectID(repositoryId), nil)
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|