2015-10-21 23:14:02 +00:00
|
|
|
package store
|
|
|
|
|
2016-03-25 19:54:16 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/drone/drone/model"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2015-10-21 23:14:02 +00:00
|
|
|
type Store interface {
|
2016-03-25 19:54:16 +00:00
|
|
|
// GetUser gets a user by unique ID.
|
|
|
|
GetUser(int64) (*model.User, error)
|
|
|
|
|
|
|
|
// GetUserLogin gets a user by unique Login name.
|
|
|
|
GetUserLogin(string) (*model.User, error)
|
|
|
|
|
|
|
|
// GetUserList gets a list of all users in the system.
|
|
|
|
GetUserList() ([]*model.User, error)
|
|
|
|
|
|
|
|
// GetUserCount gets a count of all users in the system.
|
|
|
|
GetUserCount() (int, error)
|
|
|
|
|
|
|
|
// CreateUser creates a new user account.
|
|
|
|
CreateUser(*model.User) error
|
|
|
|
|
|
|
|
// UpdateUser updates a user account.
|
|
|
|
UpdateUser(*model.User) error
|
|
|
|
|
|
|
|
// DeleteUser deletes a user account.
|
|
|
|
DeleteUser(*model.User) error
|
|
|
|
|
|
|
|
// GetRepo gets a repo by unique ID.
|
|
|
|
GetRepo(int64) (*model.Repo, error)
|
|
|
|
|
|
|
|
// GetRepoName gets a repo by its full name.
|
|
|
|
GetRepoName(string) (*model.Repo, error)
|
|
|
|
|
|
|
|
// GetRepoCount gets a count of all repositories in the system.
|
|
|
|
GetRepoCount() (int, error)
|
|
|
|
|
|
|
|
// CreateRepo creates a new repository.
|
|
|
|
CreateRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// UpdateRepo updates a user repository.
|
|
|
|
UpdateRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// DeleteRepo deletes a user repository.
|
|
|
|
DeleteRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// GetBuild gets a build by unique ID.
|
|
|
|
GetBuild(int64) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildNumber gets a build by number.
|
|
|
|
GetBuildNumber(*model.Repo, int) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildRef gets a build by its ref.
|
|
|
|
GetBuildRef(*model.Repo, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildCommit gets a build by its commit sha.
|
|
|
|
GetBuildCommit(*model.Repo, string, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildLast gets the last build for the branch.
|
|
|
|
GetBuildLast(*model.Repo, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildLastBefore gets the last build before build number N.
|
|
|
|
GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildList gets a list of builds for the repository
|
|
|
|
GetBuildList(*model.Repo) ([]*model.Build, error)
|
|
|
|
|
2016-05-11 05:19:45 +00:00
|
|
|
// GetBuildQueue gets a list of build in queue.
|
|
|
|
GetBuildQueue() ([]*model.Feed, error)
|
|
|
|
|
2017-07-25 19:32:22 +00:00
|
|
|
// GetBuildCount gets a count of all builds in the system.
|
|
|
|
GetBuildCount() (int, error)
|
|
|
|
|
2016-03-25 19:54:16 +00:00
|
|
|
// CreateBuild creates a new build and jobs.
|
2017-04-02 14:13:26 +00:00
|
|
|
CreateBuild(*model.Build, ...*model.Proc) error
|
2016-03-25 19:54:16 +00:00
|
|
|
|
|
|
|
// UpdateBuild updates a build.
|
|
|
|
UpdateBuild(*model.Build) error
|
|
|
|
|
2017-04-02 14:13:26 +00:00
|
|
|
//
|
2017-04-11 17:06:45 +00:00
|
|
|
// new functions
|
2017-04-02 14:13:26 +00:00
|
|
|
//
|
2016-05-11 21:37:56 +00:00
|
|
|
|
2017-07-14 19:58:38 +00:00
|
|
|
UserFeed(*model.User) ([]*model.Feed, error)
|
|
|
|
|
|
|
|
RepoList(*model.User) ([]*model.Repo, error)
|
|
|
|
RepoListLatest(*model.User) ([]*model.Feed, error)
|
|
|
|
RepoBatch([]*model.Repo) error
|
|
|
|
|
|
|
|
PermFind(user *model.User, repo *model.Repo) (*model.Perm, error)
|
|
|
|
PermUpsert(perm *model.Perm) error
|
|
|
|
PermBatch(perms []*model.Perm) error
|
|
|
|
PermDelete(perm *model.Perm) error
|
2017-07-16 17:37:16 +00:00
|
|
|
PermFlush(user *model.User, before int64) error
|
2017-07-14 19:58:38 +00:00
|
|
|
|
2017-05-05 16:59:37 +00:00
|
|
|
ConfigLoad(int64) (*model.Config, error)
|
|
|
|
ConfigFind(*model.Repo, string) (*model.Config, error)
|
2017-05-05 18:05:42 +00:00
|
|
|
ConfigFindApproved(*model.Config) (bool, error)
|
|
|
|
ConfigCreate(*model.Config) error
|
2017-05-05 16:59:37 +00:00
|
|
|
|
2017-04-11 17:06:45 +00:00
|
|
|
SenderFind(*model.Repo, string) (*model.Sender, error)
|
|
|
|
SenderList(*model.Repo) ([]*model.Sender, error)
|
|
|
|
SenderCreate(*model.Sender) error
|
|
|
|
SenderUpdate(*model.Sender) error
|
|
|
|
SenderDelete(*model.Sender) error
|
|
|
|
|
|
|
|
SecretFind(*model.Repo, string) (*model.Secret, error)
|
|
|
|
SecretList(*model.Repo) ([]*model.Secret, error)
|
|
|
|
SecretCreate(*model.Secret) error
|
|
|
|
SecretUpdate(*model.Secret) error
|
|
|
|
SecretDelete(*model.Secret) error
|
2016-05-11 21:37:56 +00:00
|
|
|
|
2017-04-06 12:51:01 +00:00
|
|
|
RegistryFind(*model.Repo, string) (*model.Registry, error)
|
|
|
|
RegistryList(*model.Repo) ([]*model.Registry, error)
|
|
|
|
RegistryCreate(*model.Registry) error
|
|
|
|
RegistryUpdate(*model.Registry) error
|
|
|
|
RegistryDelete(*model.Registry) error
|
2017-03-28 08:53:06 +00:00
|
|
|
|
2017-04-01 11:17:04 +00:00
|
|
|
ProcLoad(int64) (*model.Proc, error)
|
2017-03-28 08:53:06 +00:00
|
|
|
ProcFind(*model.Build, int) (*model.Proc, error)
|
|
|
|
ProcChild(*model.Build, int, string) (*model.Proc, error)
|
|
|
|
ProcList(*model.Build) ([]*model.Proc, error)
|
|
|
|
ProcCreate([]*model.Proc) error
|
|
|
|
ProcUpdate(*model.Proc) error
|
2017-04-04 10:50:15 +00:00
|
|
|
ProcClear(*model.Build) error
|
2017-03-28 08:53:06 +00:00
|
|
|
|
2017-04-03 09:34:37 +00:00
|
|
|
LogFind(*model.Proc) (io.ReadCloser, error)
|
|
|
|
LogSave(*model.Proc, io.Reader) error
|
|
|
|
|
2017-03-28 08:53:06 +00:00
|
|
|
FileList(*model.Build) ([]*model.File, error)
|
|
|
|
FileFind(*model.Proc, string) (*model.File, error)
|
|
|
|
FileRead(*model.Proc, string) (io.ReadCloser, error)
|
|
|
|
FileCreate(*model.File, io.Reader) error
|
2017-04-14 11:32:36 +00:00
|
|
|
|
|
|
|
TaskList() ([]*model.Task, error)
|
|
|
|
TaskInsert(*model.Task) error
|
|
|
|
TaskDelete(string) error
|
2016-03-25 19:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetUser gets a user by unique ID.
|
|
|
|
func GetUser(c context.Context, id int64) (*model.User, error) {
|
|
|
|
return FromContext(c).GetUser(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetUserLogin gets a user by unique Login name.
|
|
|
|
func GetUserLogin(c context.Context, login string) (*model.User, error) {
|
|
|
|
return FromContext(c).GetUserLogin(login)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetUserList gets a list of all users in the system.
|
|
|
|
func GetUserList(c context.Context) ([]*model.User, error) {
|
|
|
|
return FromContext(c).GetUserList()
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetUserCount gets a count of all users in the system.
|
|
|
|
func GetUserCount(c context.Context) (int, error) {
|
|
|
|
return FromContext(c).GetUserCount()
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateUser(c context.Context, user *model.User) error {
|
|
|
|
return FromContext(c).CreateUser(user)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UpdateUser(c context.Context, user *model.User) error {
|
|
|
|
return FromContext(c).UpdateUser(user)
|
|
|
|
}
|
|
|
|
|
|
|
|
func DeleteUser(c context.Context, user *model.User) error {
|
|
|
|
return FromContext(c).DeleteUser(user)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetRepo(c context.Context, id int64) (*model.Repo, error) {
|
|
|
|
return FromContext(c).GetRepo(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetRepoName(c context.Context, name string) (*model.Repo, error) {
|
|
|
|
return FromContext(c).GetRepoName(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetRepoOwnerName(c context.Context, owner, name string) (*model.Repo, error) {
|
|
|
|
return FromContext(c).GetRepoName(owner + "/" + name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateRepo(c context.Context, repo *model.Repo) error {
|
|
|
|
return FromContext(c).CreateRepo(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UpdateRepo(c context.Context, repo *model.Repo) error {
|
|
|
|
return FromContext(c).UpdateRepo(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func DeleteRepo(c context.Context, repo *model.Repo) error {
|
|
|
|
return FromContext(c).DeleteRepo(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuild(c context.Context, id int64) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuild(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildNumber(c context.Context, repo *model.Repo, num int) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildNumber(repo, num)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildRef(c context.Context, repo *model.Repo, ref string) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildRef(repo, ref)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildCommit(c context.Context, repo *model.Repo, sha, branch string) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildCommit(repo, sha, branch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildLast(c context.Context, repo *model.Repo, branch string) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildLast(repo, branch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildLastBefore(c context.Context, repo *model.Repo, branch string, number int64) (*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildLastBefore(repo, branch, number)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBuildList(c context.Context, repo *model.Repo) ([]*model.Build, error) {
|
|
|
|
return FromContext(c).GetBuildList(repo)
|
|
|
|
}
|
|
|
|
|
2016-05-11 05:19:45 +00:00
|
|
|
func GetBuildQueue(c context.Context) ([]*model.Feed, error) {
|
|
|
|
return FromContext(c).GetBuildQueue()
|
|
|
|
}
|
|
|
|
|
2017-04-02 14:13:26 +00:00
|
|
|
func CreateBuild(c context.Context, build *model.Build, procs ...*model.Proc) error {
|
|
|
|
return FromContext(c).CreateBuild(build, procs...)
|
2016-03-25 19:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func UpdateBuild(c context.Context, build *model.Build) error {
|
|
|
|
return FromContext(c).UpdateBuild(build)
|
|
|
|
}
|