forked from harness/harness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builds.go
71 lines (52 loc) · 2.18 KB
/
builds.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package store
import (
"github.com/drone/drone/model"
"golang.org/x/net/context"
)
type BuildStore interface {
// Get gets a build by unique ID.
Get(int64) (*model.Build, error)
// GetNumber gets a build by number.
GetNumber(*model.Repo, int) (*model.Build, error)
// GetRef gets a build by its ref.
GetRef(*model.Repo, string) (*model.Build, error)
// GetCommit gets a build by its commit sha.
GetCommit(*model.Repo, string, string) (*model.Build, error)
// GetLast gets the last build for the branch.
GetLast(*model.Repo, string) (*model.Build, error)
// GetLastBefore gets the last build before build number N.
GetLastBefore(*model.Repo, string, int64) (*model.Build, error)
// GetList gets a list of builds for the repository
GetList(*model.Repo) ([]*model.Build, error)
// Create creates a new build and jobs.
Create(*model.Build, ...*model.Job) error
// Update updates a build.
Update(*model.Build) error
}
func GetBuild(c context.Context, id int64) (*model.Build, error) {
return FromContext(c).Builds().Get(id)
}
func GetBuildNumber(c context.Context, repo *model.Repo, num int) (*model.Build, error) {
return FromContext(c).Builds().GetNumber(repo, num)
}
func GetBuildRef(c context.Context, repo *model.Repo, ref string) (*model.Build, error) {
return FromContext(c).Builds().GetRef(repo, ref)
}
func GetBuildCommit(c context.Context, repo *model.Repo, sha, branch string) (*model.Build, error) {
return FromContext(c).Builds().GetCommit(repo, sha, branch)
}
func GetBuildLast(c context.Context, repo *model.Repo, branch string) (*model.Build, error) {
return FromContext(c).Builds().GetLast(repo, branch)
}
func GetBuildLastBefore(c context.Context, repo *model.Repo, branch string, number int64) (*model.Build, error) {
return FromContext(c).Builds().GetLastBefore(repo, branch, number)
}
func GetBuildList(c context.Context, repo *model.Repo) ([]*model.Build, error) {
return FromContext(c).Builds().GetList(repo)
}
func CreateBuild(c context.Context, build *model.Build, jobs ...*model.Job) error {
return FromContext(c).Builds().Create(build, jobs...)
}
func UpdateBuild(c context.Context, build *model.Build) error {
return FromContext(c).Builds().Update(build)
}