2021-05-08 22:25:31 +02:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ansible-semaphore/semaphore/db"
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
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) {
|
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 {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObject(projectID, db.RepositoryProps, intObjectID(repositoryId))
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) DeleteRepositorySoft(projectID int, repositoryId int) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.deleteObjectSoft(projectID, db.RepositoryProps, intObjectID(repositoryId))
|
2021-05-08 22:25:31 +02:00
|
|
|
}
|
|
|
|
|