mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-23 17:53:23 +02:00
Remove some wrapper and make code more redable (#478)
* meaningful var names * no context wrapper, use store directly * retrieve store from context once * rm store.GetRepoOwnerName
This commit is contained in:
parent
473a05d5b5
commit
965235e421
@ -38,10 +38,8 @@ var (
|
||||
)
|
||||
|
||||
func GetBadge(c *gin.Context) {
|
||||
repo, err := store.GetRepoOwnerName(c,
|
||||
c.Param("owner"),
|
||||
c.Param("name"),
|
||||
)
|
||||
store_ := store.FromContext(c)
|
||||
repo, err := store_.GetRepoName(c.Param("owner") + "/" + c.Param("name"))
|
||||
if err != nil {
|
||||
c.AbortWithStatus(404)
|
||||
return
|
||||
@ -59,7 +57,7 @@ func GetBadge(c *gin.Context) {
|
||||
branch = repo.Branch
|
||||
}
|
||||
|
||||
build, err := store.GetBuildLast(c, repo, branch)
|
||||
build, err := store_.GetBuildLast(repo, branch)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("")
|
||||
c.String(200, badgeNone)
|
||||
@ -81,16 +79,14 @@ func GetBadge(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetCC(c *gin.Context) {
|
||||
repo, err := store.GetRepoOwnerName(c,
|
||||
c.Param("owner"),
|
||||
c.Param("name"),
|
||||
)
|
||||
store_ := store.FromContext(c)
|
||||
repo, err := store_.GetRepoName(c.Param("owner") + "/" + c.Param("name"))
|
||||
if err != nil {
|
||||
c.AbortWithStatus(404)
|
||||
return
|
||||
}
|
||||
|
||||
builds, err := store.GetBuildList(c, repo, 1)
|
||||
builds, err := store_.GetBuildList(repo, 1)
|
||||
if err != nil || len(builds) == 0 {
|
||||
c.AbortWithStatus(404)
|
||||
return
|
||||
|
@ -46,7 +46,7 @@ func GetBuilds(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
builds, err := store.GetBuildList(c, repo, page)
|
||||
builds, err := store.FromContext(c).GetBuildList(repo, page)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@ -55,6 +55,7 @@ func GetBuilds(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetBuild(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
if c.Param("number") == "latest" {
|
||||
GetBuildLast(c)
|
||||
return
|
||||
@ -67,13 +68,13 @@ func GetBuild(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
files, _ := store.FromContext(c).FileList(build)
|
||||
procs, _ := store.FromContext(c).ProcList(build)
|
||||
files, _ := store_.FileList(build)
|
||||
procs, _ := store_.ProcList(build)
|
||||
build.Procs = model.Tree(procs)
|
||||
build.Files = files
|
||||
|
||||
@ -81,21 +82,23 @@ func GetBuild(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetBuildLast(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
branch := c.DefaultQuery("branch", repo.Branch)
|
||||
|
||||
build, err := store.GetBuildLast(c, repo, branch)
|
||||
build, err := store_.GetBuildLast(repo, branch)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
procs, _ := store.FromContext(c).ProcList(build)
|
||||
procs, _ := store_.ProcList(build)
|
||||
build.Procs = model.Tree(procs)
|
||||
c.JSON(http.StatusOK, build)
|
||||
}
|
||||
|
||||
func GetBuildLogs(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
// parse the build number and job sequence number from
|
||||
@ -104,19 +107,19 @@ func GetBuildLogs(c *gin.Context) {
|
||||
ppid, _ := strconv.Atoi(c.Params.ByName("pid"))
|
||||
name := c.Params.ByName("proc")
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
proc, err := store.FromContext(c).ProcChild(build, ppid, name)
|
||||
proc, err := store_.ProcChild(build, ppid, name)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
rc, err := store.FromContext(c).LogFind(proc)
|
||||
rc, err := store_.LogFind(proc)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -129,6 +132,7 @@ func GetBuildLogs(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetProcLogs(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
// parse the build number and job sequence number from
|
||||
@ -136,19 +140,19 @@ func GetProcLogs(c *gin.Context) {
|
||||
num, _ := strconv.Atoi(c.Params.ByName("number"))
|
||||
pid, _ := strconv.Atoi(c.Params.ByName("pid"))
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
proc, err := store.FromContext(c).ProcFind(build, pid)
|
||||
proc, err := store_.ProcFind(build, pid)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
rc, err := store.FromContext(c).LogFind(proc)
|
||||
rc, err := store_.LogFind(proc)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -162,16 +166,17 @@ func GetProcLogs(c *gin.Context) {
|
||||
|
||||
// DeleteBuild cancels a build
|
||||
func DeleteBuild(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
num, _ := strconv.Atoi(c.Params.ByName("number"))
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
procs, err := store.FromContext(c).ProcList(build)
|
||||
procs, err := store_.ProcList(build)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(404, err)
|
||||
return
|
||||
@ -207,18 +212,18 @@ func DeleteBuild(c *gin.Context) {
|
||||
for _, proc := range procs {
|
||||
if proc.State == model.StatusPending {
|
||||
if proc.PPID != 0 {
|
||||
if _, err = shared.UpdateProcToStatusSkipped(store.FromContext(c), *proc, 0); err != nil {
|
||||
if _, err = shared.UpdateProcToStatusSkipped(store_, *proc, 0); err != nil {
|
||||
log.Error().Msgf("error: done: cannot update proc_id %d state: %s", proc.ID, err)
|
||||
}
|
||||
} else {
|
||||
if _, err = shared.UpdateProcToStatusKilled(store.FromContext(c), *proc); err != nil {
|
||||
if _, err = shared.UpdateProcToStatusKilled(store_, *proc); err != nil {
|
||||
log.Error().Msgf("error: done: cannot update proc_id %d state: %s", proc.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
killedBuild, err := shared.UpdateToStatusKilled(store.FromContext(c), *build)
|
||||
killedBuild, err := shared.UpdateToStatusKilled(store_, *build)
|
||||
if err != nil {
|
||||
c.AbortWithError(500, err)
|
||||
return
|
||||
@ -227,7 +232,7 @@ func DeleteBuild(c *gin.Context) {
|
||||
// For pending builds, we stream the UI the latest state.
|
||||
// For running builds, the UI will be updated when the agents acknowledge the cancel
|
||||
if build.Status == model.StatusPending {
|
||||
procs, err = store.FromContext(c).ProcList(killedBuild)
|
||||
procs, err = store_.ProcList(killedBuild)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -242,6 +247,7 @@ func DeleteBuild(c *gin.Context) {
|
||||
func PostApproval(c *gin.Context) {
|
||||
var (
|
||||
remote_ = remote.FromContext(c)
|
||||
store_ = store.FromContext(c)
|
||||
repo = session.Repo(c)
|
||||
user = session.User(c)
|
||||
num, _ = strconv.Atoi(
|
||||
@ -249,7 +255,7 @@ func PostApproval(c *gin.Context) {
|
||||
)
|
||||
)
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -273,7 +279,7 @@ func PostApproval(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if build, err = shared.UpdateToStatusPending(store.FromContext(c), *build, user.Login); err != nil {
|
||||
if build, err = shared.UpdateToStatusPending(store_, *build, user.Login); err != nil {
|
||||
c.String(500, "error updating build. %s", err)
|
||||
return
|
||||
}
|
||||
@ -282,7 +288,7 @@ func PostApproval(c *gin.Context) {
|
||||
|
||||
// get the previous build so that we can send
|
||||
// on status change notifications
|
||||
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
|
||||
last, _ := store_.GetBuildLastBefore(repo, build.Branch, build.ID)
|
||||
secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build)
|
||||
if err != nil {
|
||||
log.Debug().Msgf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err)
|
||||
@ -317,14 +323,14 @@ func PostApproval(c *gin.Context) {
|
||||
}
|
||||
buildItems, err := b.Build()
|
||||
if err != nil {
|
||||
if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); err != nil {
|
||||
if _, err = shared.UpdateToStatusError(store_, *build, err); err != nil {
|
||||
log.Error().Msgf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
build = shared.SetBuildStepsOnBuild(b.Curr, buildItems)
|
||||
|
||||
err = store.FromContext(c).ProcCreate(build.Procs)
|
||||
err = store_.ProcCreate(build.Procs)
|
||||
if err != nil {
|
||||
log.Error().Msgf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err)
|
||||
}
|
||||
@ -350,14 +356,16 @@ func PostApproval(c *gin.Context) {
|
||||
func PostDecline(c *gin.Context) {
|
||||
var (
|
||||
remote_ = remote.FromContext(c)
|
||||
repo = session.Repo(c)
|
||||
user = session.User(c)
|
||||
num, _ = strconv.Atoi(
|
||||
store_ = store.FromContext(c)
|
||||
|
||||
repo = session.Repo(c)
|
||||
user = session.User(c)
|
||||
num, _ = strconv.Atoi(
|
||||
c.Params.ByName("number"),
|
||||
)
|
||||
)
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -367,7 +375,7 @@ func PostDecline(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = shared.UpdateToStatusDeclined(store.FromContext(c), *build, user.Login); err != nil {
|
||||
if _, err = shared.UpdateToStatusDeclined(store_, *build, user.Login); err != nil {
|
||||
c.String(500, "error updating build. %s", err)
|
||||
return
|
||||
}
|
||||
@ -382,7 +390,7 @@ func PostDecline(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetBuildQueue(c *gin.Context) {
|
||||
out, err := store.GetBuildQueue(c)
|
||||
out, err := store.FromContext(c).GetBuildQueue()
|
||||
if err != nil {
|
||||
c.String(500, "Error getting build queue. %s", err)
|
||||
return
|
||||
@ -393,6 +401,7 @@ func GetBuildQueue(c *gin.Context) {
|
||||
// PostBuild restarts a build
|
||||
func PostBuild(c *gin.Context) {
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
num, err := strconv.Atoi(c.Param("number"))
|
||||
@ -401,14 +410,14 @@ func PostBuild(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := store.GetUser(c, repo.UserID)
|
||||
user, err := store_.GetUser(repo.UserID)
|
||||
if err != nil {
|
||||
log.Error().Msgf("failure to find repo owner %s. %s", repo.FullName, err)
|
||||
c.AbortWithError(500, err)
|
||||
return
|
||||
}
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
log.Error().Msgf("failure to get build %d. %s", num, err)
|
||||
c.AbortWithError(404, err)
|
||||
@ -428,7 +437,7 @@ func PostBuild(c *gin.Context) {
|
||||
if refresher, ok := remote_.(remote.Refresher); ok {
|
||||
ok, _ := refresher.Refresh(c, user)
|
||||
if ok {
|
||||
store.UpdateUser(c, user)
|
||||
store_.UpdateUser(user)
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +474,7 @@ func PostBuild(c *gin.Context) {
|
||||
build.Event = event
|
||||
}
|
||||
|
||||
err = store.CreateBuild(c, build)
|
||||
err = store_.CreateBuild(build)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
@ -492,7 +501,7 @@ func PostBuild(c *gin.Context) {
|
||||
|
||||
// get the previous build so that we can send
|
||||
// on status change notifications
|
||||
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
|
||||
last, _ := store_.GetBuildLastBefore(repo, build.Branch, build.ID)
|
||||
secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build)
|
||||
if err != nil {
|
||||
log.Debug().Msgf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err)
|
||||
@ -535,7 +544,7 @@ func PostBuild(c *gin.Context) {
|
||||
}
|
||||
build = shared.SetBuildStepsOnBuild(b.Curr, buildItems)
|
||||
|
||||
err = store.FromContext(c).ProcCreate(build.Procs)
|
||||
err = store_.ProcCreate(build.Procs)
|
||||
if err != nil {
|
||||
log.Error().Msgf("cannot restart %s#%d: %s", repo.FullName, build.Number, err)
|
||||
build.Status = model.StatusError
|
||||
@ -552,17 +561,19 @@ func PostBuild(c *gin.Context) {
|
||||
}
|
||||
|
||||
func DeleteBuildLogs(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
num, _ := strconv.Atoi(c.Params.ByName("number"))
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
}
|
||||
|
||||
procs, err := store.FromContext(c).ProcList(build)
|
||||
procs, err := store_.ProcList(build)
|
||||
if err != nil {
|
||||
c.AbortWithError(404, err)
|
||||
return
|
||||
@ -577,7 +588,7 @@ func DeleteBuildLogs(c *gin.Context) {
|
||||
for _, proc := range procs {
|
||||
t := time.Now().UTC()
|
||||
buf := bytes.NewBufferString(fmt.Sprintf(deleteStr, proc.Name, user.Login, t.Format(time.UnixDate)))
|
||||
lerr := store.FromContext(c).LogSave(proc, buf)
|
||||
lerr := store_.LogSave(proc, buf)
|
||||
if lerr != nil {
|
||||
err = lerr
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
|
||||
// FileList gets a list file by build.
|
||||
func FileList(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
num, err := strconv.Atoi(c.Param("number"))
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
@ -35,13 +36,13 @@ func FileList(c *gin.Context) {
|
||||
}
|
||||
|
||||
repo := session.Repo(c)
|
||||
build, err := store.FromContext(c).GetBuildNumber(repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
files, err := store.FromContext(c).FileList(build)
|
||||
files, err := store_.FileList(build)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -53,6 +54,8 @@ func FileList(c *gin.Context) {
|
||||
// FileGet gets a file by process and name
|
||||
func FileGet(c *gin.Context) {
|
||||
var (
|
||||
store_ = store.FromContext(c)
|
||||
|
||||
repo = session.Repo(c)
|
||||
name = strings.TrimPrefix(c.Param("file"), "/")
|
||||
raw = func() bool {
|
||||
@ -72,19 +75,19 @@ func FileGet(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
build, err := store.FromContext(c).GetBuildNumber(repo, num)
|
||||
build, err := store_.GetBuildNumber(repo, num)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
proc, err := store.FromContext(c).ProcFind(build, pid)
|
||||
proc, err := store_.ProcFind(build, pid)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
file, err := store.FromContext(c).FileFind(proc, name)
|
||||
file, err := store_.FileFind(proc, name)
|
||||
if err != nil {
|
||||
c.String(404, "Error getting file %q. %s", name, err)
|
||||
return
|
||||
@ -95,7 +98,7 @@ func FileGet(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rc, err := store.FromContext(c).FileRead(proc, file.Name)
|
||||
rc, err := store_.FileRead(proc, file.Name)
|
||||
if err != nil {
|
||||
c.String(404, "Error getting file stream %q. %s", name, err)
|
||||
return
|
||||
|
@ -77,6 +77,7 @@ func BlockTilQueueHasRunningItem(c *gin.Context) {
|
||||
|
||||
func PostHook(c *gin.Context) {
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
tmpRepo, build, err := remote_.Hook(c.Request)
|
||||
if err != nil {
|
||||
@ -103,7 +104,7 @@ func PostHook(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := store.GetRepoOwnerName(c, tmpRepo.Owner, tmpRepo.Name)
|
||||
repo, err := store_.GetRepoName(tmpRepo.Owner + "/" + tmpRepo.Name)
|
||||
if err != nil {
|
||||
log.Error().Msgf("failure to find repo %s/%s from hook. %s", tmpRepo.Owner, tmpRepo.Name, err)
|
||||
c.AbortWithError(404, err)
|
||||
@ -143,7 +144,7 @@ func PostHook(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := store.GetUser(c, repo.UserID)
|
||||
user, err := store_.GetUser(repo.UserID)
|
||||
if err != nil {
|
||||
log.Error().Msgf("failure to find repo owner %s. %s", repo.FullName, err)
|
||||
c.AbortWithError(500, err)
|
||||
@ -158,7 +159,7 @@ func PostHook(c *gin.Context) {
|
||||
if err != nil {
|
||||
log.Error().Msgf("failed to refresh oauth2 token: %s", err)
|
||||
} else if ok {
|
||||
if err := store.UpdateUser(c, user); err != nil {
|
||||
if err := store_.UpdateUser(user); err != nil {
|
||||
log.Error().Msgf("error while updating user: %s", err)
|
||||
// move forward
|
||||
}
|
||||
@ -198,7 +199,7 @@ func PostHook(c *gin.Context) {
|
||||
build.Status = model.StatusBlocked
|
||||
}
|
||||
|
||||
err = store.CreateBuild(c, build, build.Procs...)
|
||||
err = store_.CreateBuild(build, build.Procs...)
|
||||
if err != nil {
|
||||
log.Error().Msgf("failure to save commit for %s. %s", repo.FullName, err)
|
||||
c.AbortWithError(500, err)
|
||||
@ -246,7 +247,7 @@ func PostHook(c *gin.Context) {
|
||||
}
|
||||
|
||||
// get the previous build so that we can send status change notifications
|
||||
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
|
||||
last, _ := store_.GetBuildLastBefore(repo, build.Branch, build.ID)
|
||||
|
||||
b := shared.ProcBuilder{
|
||||
Repo: repo,
|
||||
@ -261,14 +262,14 @@ func PostHook(c *gin.Context) {
|
||||
}
|
||||
buildItems, err := b.Build()
|
||||
if err != nil {
|
||||
if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); err != nil {
|
||||
if _, err = shared.UpdateToStatusError(store_, *build, err); err != nil {
|
||||
log.Error().Msgf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
build = shared.SetBuildStepsOnBuild(b.Curr, buildItems)
|
||||
|
||||
err = store.FromContext(c).ProcCreate(build.Procs)
|
||||
err = store_.ProcCreate(build.Procs)
|
||||
if err != nil {
|
||||
log.Error().Msgf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err)
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ func HandleLogin(c *gin.Context) {
|
||||
}
|
||||
|
||||
func HandleAuth(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
// when dealing with redirects we may need to adjust the content type. I
|
||||
// cannot, however, remember why, so need to revisit this line.
|
||||
@ -68,7 +69,7 @@ func HandleAuth(c *gin.Context) {
|
||||
config := ToConfig(c)
|
||||
|
||||
// get the user from the database
|
||||
u, err := store.GetUserLogin(c, tmpuser.Login)
|
||||
u, err := store_.GetUserLogin(tmpuser.Login)
|
||||
if err != nil {
|
||||
|
||||
// if self-registration is disabled we should return a not authorized error
|
||||
@ -102,7 +103,7 @@ func HandleAuth(c *gin.Context) {
|
||||
}
|
||||
|
||||
// insert the user into the database
|
||||
if err := store.CreateUser(c, u); err != nil {
|
||||
if err := store_.CreateUser(u); err != nil {
|
||||
log.Error().Msgf("cannot insert %s. %s", u.Login, err)
|
||||
c.Redirect(303, "/login?error=internal_error")
|
||||
return
|
||||
@ -126,7 +127,7 @@ func HandleAuth(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := store.UpdateUser(c, u); err != nil {
|
||||
if err := store_.UpdateUser(u); err != nil {
|
||||
log.Error().Msgf("cannot update %s. %s", u.Login, err)
|
||||
c.Redirect(303, "/login?error=internal_error")
|
||||
return
|
||||
@ -157,6 +158,8 @@ func GetLogout(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetLoginToken(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
in := &tokenPayload{}
|
||||
err := c.Bind(in)
|
||||
if err != nil {
|
||||
@ -170,7 +173,7 @@ func GetLoginToken(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := store.GetUserLogin(c, login)
|
||||
user, err := store_.GetUserLogin(login)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
|
@ -32,7 +32,8 @@ import (
|
||||
)
|
||||
|
||||
func PostRepo(c *gin.Context) {
|
||||
r := remote.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
user := session.User(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
@ -76,18 +77,18 @@ func PostRepo(c *gin.Context) {
|
||||
sig,
|
||||
)
|
||||
|
||||
err = r.Activate(c, user, repo, link)
|
||||
err = remote_.Activate(c, user, repo, link)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
from, err := r.Repo(c, user, repo.Owner, repo.Name)
|
||||
from, err := remote_.Repo(c, user, repo.Owner, repo.Name)
|
||||
if err == nil {
|
||||
repo.Update(from)
|
||||
}
|
||||
|
||||
err = store.UpdateRepo(c, repo)
|
||||
err = store_.UpdateRepo(repo)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
@ -97,6 +98,7 @@ func PostRepo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func PatchRepo(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
|
||||
@ -139,7 +141,7 @@ func PatchRepo(c *gin.Context) {
|
||||
repo.Counter = *in.BuildCounter
|
||||
}
|
||||
|
||||
err := store.UpdateRepo(c, repo)
|
||||
err := store_.UpdateRepo(repo)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -149,11 +151,12 @@ func PatchRepo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func ChownRepo(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
repo.UserID = user.ID
|
||||
|
||||
err := store.UpdateRepo(c, repo)
|
||||
err := store_.UpdateRepo(repo)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -186,28 +189,30 @@ func GetRepoBranches(c *gin.Context) {
|
||||
|
||||
func DeleteRepo(c *gin.Context) {
|
||||
remove, _ := strconv.ParseBool(c.Query("remove"))
|
||||
r := remote.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
|
||||
repo.IsActive = false
|
||||
repo.UserID = 0
|
||||
|
||||
err := store.UpdateRepo(c, repo)
|
||||
err := store_.UpdateRepo(repo)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
if remove {
|
||||
err := store.DeleteRepo(c, repo)
|
||||
err := store_.DeleteRepo(repo)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.Deactivate(c, user, repo, server.Config.Server.Host); err != nil {
|
||||
if err := remote_.Deactivate(c, user, repo, server.Config.Server.Host); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
@ -215,7 +220,8 @@ func DeleteRepo(c *gin.Context) {
|
||||
}
|
||||
|
||||
func RepairRepo(c *gin.Context) {
|
||||
r := remote.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
|
||||
@ -235,14 +241,14 @@ func RepairRepo(c *gin.Context) {
|
||||
sig,
|
||||
)
|
||||
|
||||
_ = r.Deactivate(c, user, repo, host)
|
||||
err = r.Activate(c, user, repo, link)
|
||||
_ = remote_.Deactivate(c, user, repo, host)
|
||||
err = remote_.Activate(c, user, repo, link)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
from, err := r.Repo(c, user, repo.Owner, repo.Name)
|
||||
from, err := remote_.Repo(c, user, repo.Owner, repo.Name)
|
||||
if err == nil {
|
||||
repo.Name = from.Name
|
||||
repo.Owner = from.Owner
|
||||
@ -254,14 +260,15 @@ func RepairRepo(c *gin.Context) {
|
||||
if repo.IsPrivate != from.IsPrivate {
|
||||
repo.ResetVisibility()
|
||||
}
|
||||
store.UpdateRepo(c, repo)
|
||||
store_.UpdateRepo(repo)
|
||||
}
|
||||
|
||||
c.Writer.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func MoveRepo(c *gin.Context) {
|
||||
r := remote.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
store_ := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
|
||||
@ -278,7 +285,7 @@ func MoveRepo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
from, err := r.Repo(c, user, owner, name)
|
||||
from, err := remote_.Repo(c, user, owner, name)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
@ -299,7 +306,7 @@ func MoveRepo(c *gin.Context) {
|
||||
repo.ResetVisibility()
|
||||
}
|
||||
|
||||
errStore := store.UpdateRepo(c, repo)
|
||||
errStore := store_.UpdateRepo(repo)
|
||||
if errStore != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, errStore)
|
||||
return
|
||||
@ -322,8 +329,8 @@ func MoveRepo(c *gin.Context) {
|
||||
)
|
||||
|
||||
// TODO: check if we should handle that error
|
||||
r.Deactivate(c, user, repo, host)
|
||||
err = r.Activate(c, user, repo, link)
|
||||
remote_.Deactivate(c, user, repo, host)
|
||||
err = remote_.Activate(c, user, repo, link)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
|
@ -133,37 +133,21 @@ func LogStreamSSE(c *gin.Context) {
|
||||
io.WriteString(rw, ": ping\n\n")
|
||||
flusher.Flush()
|
||||
|
||||
// repo := session.Repo(c)
|
||||
//
|
||||
repo := session.Repo(c)
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
// // parse the build number and job sequence number from
|
||||
// // the repquest parameter.
|
||||
// num, _ := strconv.Atoi(c.Params.ByName("number"))
|
||||
// ppid, _ := strconv.Atoi(c.Params.ByName("ppid"))
|
||||
// name := c.Params.ByName("proc")
|
||||
//
|
||||
// build, err := store.GetBuildNumber(c, repo, num)
|
||||
// if err != nil {
|
||||
// c.AbortWithError(404, err)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// proc, err := store.FromContext(c).ProcChild(build, ppid, name)
|
||||
// if err != nil {
|
||||
// c.AbortWithError(404, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
repo := session.Repo(c)
|
||||
buildn, _ := strconv.Atoi(c.Param("build"))
|
||||
jobn, _ := strconv.Atoi(c.Param("number"))
|
||||
|
||||
build, err := store.GetBuildNumber(c, repo, buildn)
|
||||
build, err := store_.GetBuildNumber(repo, buildn)
|
||||
if err != nil {
|
||||
log.Debug().Msgf("stream cannot get build number: %v", err)
|
||||
io.WriteString(rw, "event: error\ndata: build not found\n\n")
|
||||
return
|
||||
}
|
||||
proc, err := store.FromContext(c).ProcFind(build, jobn)
|
||||
proc, err := store_.ProcFind(build, jobn)
|
||||
if err != nil {
|
||||
log.Debug().Msgf("stream cannot get proc number: %v", err)
|
||||
io.WriteString(rw, "event: error\ndata: process not found\n\n")
|
||||
|
@ -37,6 +37,9 @@ func GetSelf(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetFeed(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
|
||||
user := session.User(c)
|
||||
latest, _ := strconv.ParseBool(c.Query("latest"))
|
||||
|
||||
@ -44,14 +47,14 @@ func GetFeed(c *gin.Context) {
|
||||
log.Debug().Msgf("sync begin: %s", user.Login)
|
||||
|
||||
user.Synced = time.Now().Unix()
|
||||
store.FromContext(c).UpdateUser(user)
|
||||
store_.UpdateUser(user)
|
||||
|
||||
config := ToConfig(c)
|
||||
|
||||
sync := shared.Syncer{
|
||||
Remote: remote.FromContext(c),
|
||||
Store: store.FromContext(c),
|
||||
Perms: store.FromContext(c),
|
||||
Remote: remote_,
|
||||
Store: store_,
|
||||
Perms: store_,
|
||||
Match: shared.NamespaceFilter(config.OwnersWhitelist),
|
||||
}
|
||||
if err := sync.Sync(c, user); err != nil {
|
||||
@ -62,7 +65,7 @@ func GetFeed(c *gin.Context) {
|
||||
}
|
||||
|
||||
if latest {
|
||||
feed, err := store.FromContext(c).RepoListLatest(user)
|
||||
feed, err := store_.RepoListLatest(user)
|
||||
if err != nil {
|
||||
c.String(500, "Error fetching feed. %s", err)
|
||||
} else {
|
||||
@ -71,7 +74,7 @@ func GetFeed(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
feed, err := store.FromContext(c).UserFeed(user)
|
||||
feed, err := store_.UserFeed(user)
|
||||
if err != nil {
|
||||
c.String(500, "Error fetching user feed. %s", err)
|
||||
return
|
||||
@ -80,23 +83,24 @@ func GetFeed(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetRepos(c *gin.Context) {
|
||||
var (
|
||||
user = session.User(c)
|
||||
all, _ = strconv.ParseBool(c.Query("all"))
|
||||
flush, _ = strconv.ParseBool(c.Query("flush"))
|
||||
)
|
||||
store_ := store.FromContext(c)
|
||||
remote_ := remote.FromContext(c)
|
||||
|
||||
user := session.User(c)
|
||||
all, _ := strconv.ParseBool(c.Query("all"))
|
||||
flush, _ := strconv.ParseBool(c.Query("flush"))
|
||||
|
||||
if flush || time.Unix(user.Synced, 0).Add(time.Hour*72).Before(time.Now()) {
|
||||
log.Debug().Msgf("sync begin: %s", user.Login)
|
||||
user.Synced = time.Now().Unix()
|
||||
store.FromContext(c).UpdateUser(user)
|
||||
store_.UpdateUser(user)
|
||||
|
||||
config := ToConfig(c)
|
||||
|
||||
sync := shared.Syncer{
|
||||
Remote: remote.FromContext(c),
|
||||
Store: store.FromContext(c),
|
||||
Perms: store.FromContext(c),
|
||||
Remote: remote_,
|
||||
Store: store_,
|
||||
Perms: store_,
|
||||
Match: shared.NamespaceFilter(config.OwnersWhitelist),
|
||||
}
|
||||
|
||||
@ -107,7 +111,7 @@ func GetRepos(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
repos, err := store.FromContext(c).RepoList(user, true)
|
||||
repos, err := store_.RepoList(user, true)
|
||||
if err != nil {
|
||||
c.String(500, "Error fetching repository list. %s", err)
|
||||
return
|
||||
@ -138,11 +142,13 @@ func PostToken(c *gin.Context) {
|
||||
}
|
||||
|
||||
func DeleteToken(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
user := session.User(c)
|
||||
user.Hash = base32.StdEncoding.EncodeToString(
|
||||
securecookie.GenerateRandomKey(32),
|
||||
)
|
||||
if err := store.UpdateUser(c, user); err != nil {
|
||||
if err := store_.UpdateUser(user); err != nil {
|
||||
c.String(500, "Error revoking tokens. %s", err)
|
||||
return
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func GetUsers(c *gin.Context) {
|
||||
users, err := store.GetUserList(c)
|
||||
users, err := store.FromContext(c).GetUserList()
|
||||
if err != nil {
|
||||
c.String(500, "Error getting user list. %s", err)
|
||||
return
|
||||
@ -35,7 +35,7 @@ func GetUsers(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetUser(c *gin.Context) {
|
||||
user, err := store.GetUserLogin(c, c.Param("login"))
|
||||
user, err := store.FromContext(c).GetUserLogin(c.Param("login"))
|
||||
if err != nil {
|
||||
c.String(404, "Cannot find user. %s", err)
|
||||
return
|
||||
@ -44,6 +44,8 @@ func GetUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
func PatchUser(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
in := &model.User{}
|
||||
err := c.Bind(in)
|
||||
if err != nil {
|
||||
@ -51,14 +53,14 @@ func PatchUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := store.GetUserLogin(c, c.Param("login"))
|
||||
user, err := store_.GetUserLogin(c.Param("login"))
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
user.Active = in.Active
|
||||
|
||||
err = store.UpdateUser(c, user)
|
||||
err = store_.UpdateUser(user)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusConflict)
|
||||
return
|
||||
@ -87,7 +89,7 @@ func PostUser(c *gin.Context) {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if err = store.CreateUser(c, user); err != nil {
|
||||
if err = store.FromContext(c).CreateUser(user); err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
@ -95,12 +97,14 @@ func PostUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
func DeleteUser(c *gin.Context) {
|
||||
user, err := store.GetUserLogin(c, c.Param("login"))
|
||||
store_ := store.FromContext(c)
|
||||
|
||||
user, err := store_.GetUserLogin(c.Param("login"))
|
||||
if err != nil {
|
||||
c.String(404, "Cannot find user. %s", err)
|
||||
return
|
||||
}
|
||||
if err = store.DeleteUser(c, user); err != nil {
|
||||
if err = store_.DeleteUser(user); err != nil {
|
||||
c.String(500, "Error deleting user. %s", err)
|
||||
return
|
||||
}
|
||||
|
@ -42,12 +42,13 @@ func Repo(c *gin.Context) *model.Repo {
|
||||
func SetRepo() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
var (
|
||||
owner = c.Param("owner")
|
||||
name = c.Param("name")
|
||||
user = User(c)
|
||||
store_ = store.FromContext(c)
|
||||
owner = c.Param("owner")
|
||||
name = c.Param("name")
|
||||
user = User(c)
|
||||
)
|
||||
|
||||
repo, err := store.GetRepoOwnerName(c, owner, name)
|
||||
repo, err := store_.GetRepoName(owner + "/" + name)
|
||||
if err == nil {
|
||||
c.Set("repo", repo)
|
||||
c.Next()
|
||||
@ -83,6 +84,7 @@ func Perm(c *gin.Context) *model.Perm {
|
||||
|
||||
func SetPerm() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
store_ := store.FromContext(c)
|
||||
user := User(c)
|
||||
repo := Repo(c)
|
||||
perm := new(model.Perm)
|
||||
@ -90,7 +92,7 @@ func SetPerm() gin.HandlerFunc {
|
||||
switch {
|
||||
case user != nil:
|
||||
var err error
|
||||
perm, err = store.FromContext(c).PermFind(user, repo)
|
||||
perm, err = store_.PermFind(user, repo)
|
||||
if err != nil {
|
||||
log.Error().Msgf("Error fetching permission for %s %s. %s",
|
||||
user.Login, repo.FullName, err)
|
||||
@ -102,7 +104,7 @@ func SetPerm() gin.HandlerFunc {
|
||||
perm.Repo = repo.FullName
|
||||
perm.UserID = user.ID
|
||||
perm.Synced = time.Now().Unix()
|
||||
store.FromContext(c).PermUpsert(perm)
|
||||
store_.PermUpsert(perm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func SetUser() gin.HandlerFunc {
|
||||
|
||||
t, err := token.ParseRequest(c.Request, func(t *token.Token) (string, error) {
|
||||
var err error
|
||||
user, err = store.GetUserLogin(c, t.Text)
|
||||
user, err = store.FromContext(c).GetUserLogin(t.Text)
|
||||
return user.Hash, err
|
||||
})
|
||||
if err == nil {
|
||||
|
@ -55,7 +55,7 @@ func Refresh(c *gin.Context) {
|
||||
// database.
|
||||
ok, _ = refresher.Refresh(c, user)
|
||||
if ok {
|
||||
err := store.UpdateUser(c, user)
|
||||
err := store.FromContext(c).UpdateUser(user)
|
||||
if err != nil {
|
||||
// we only log the error at this time. not sure
|
||||
// if we really want to fail the request, do we?
|
||||
|
@ -15,7 +15,6 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
@ -156,95 +155,3 @@ type Store interface {
|
||||
|
||||
Ping() error
|
||||
}
|
||||
|
||||
// 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, page int) ([]*model.Build, error) {
|
||||
return FromContext(c).GetBuildList(repo, page)
|
||||
}
|
||||
|
||||
func GetBuildQueue(c context.Context) ([]*model.Feed, error) {
|
||||
return FromContext(c).GetBuildQueue()
|
||||
}
|
||||
|
||||
func CreateBuild(c context.Context, build *model.Build, procs ...*model.Proc) error {
|
||||
return FromContext(c).CreateBuild(build, procs...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user